ApplicationSource

When you have a project that requires a dynamic interface, and you are adding and removing tabs, lets say you need to reset the selectedIndex of the TabNavigator back to 0, because you may be adding tabs that are not relevant to what you originally had on the screen… when you simply do a “tabNav.removeAllChildren()” on the TabNavigator, and change the selectedIndex in the same function, it just simply doesnt work… there is a bug for it… http://bugs.adobe.com/jira/browse/SDK-14157

So the more elegant solution that also pays attention to the flex framework is by using commitProperties() when you use commitProperties it guarantees that things will be done after the initialization is done in the component, it also is guarantees things will only run once per frame I believe… (don’t quote me on that, i’m just to lazy to look up where I read that, because I’ve got to get back to work)

anyway… when you use invalidateProperties() when you want to remove the children, you would simply set the selectedIndex before you invalidate, and then do the work in commitProperties… and it should just work because of the way commitProperties is supposed to work…

when in reality, it doesnt work either…

so what you end up having to do is use callLater( commitProperties )

private var _tabNavChanged:Boolean = false;
public function resetTabNav():void
{
tabNav.selectedIndex = 0;

_tabNavChanged = true;
callLater( commitProperties )
}

override protected function commitProperties():void
{
super.commitProperties():

if( _tabNavChanged )
{

//do your looping and stuff here to create your dynamic tabs...

_tabNavChanged = false;
}

}//end function

Hope this helps someone… didn’t really take long 😉 i suppose I’m just used to using commitProperties

ApplicationSource