Im loading tabs for an accordion control at runtime. The nu开发者_开发知识库mber of tabs is determined by the role of the user. Each tab comes from a module so the load time is variable. As a result the list order changes every time the app is run.
Is there a practical way to sort the tabs as each new tab is loaded?
Well that was silly of me:
in the 'ModuleEvent.Ready' handler add this code:
var childArray : Array = accordion.getChildren();
for ( var o:int = childArray.length - 1; o > 0;o-- )
{
for ( var i:int = 0; i < o;i++ )
{
if( childArray[i].label > childArray[i + 1].label )
{
var childObject : Object = accordion.removeChildAt( i + 1 );
accordion.addChildAt( childObject as DisplayObject, i );
}
}
}
resorting on every load will cause problems if you have lots of tabs.. but my list is pretty short..
精彩评论