开发者

Flex Accordion control: sort tabs?

开发者 https://www.devze.com 2023-02-10 11:41 出处:网络
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 t

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..

0

精彩评论

暂无评论...
验证码 换一张
取 消