A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: sort items in array by name

  1. #1
    Member
    Join Date
    Jul 2009
    Location
    Florianópolis
    Posts
    81

    sort items in array by name

    Hello fellows,

    I need to sort String items in an Array.
    Actually I need to organize children of a MOvieClip inside an Array.

    I have a "menu" mc object which has 8 children with names "m1", "m2", and so on..... the last one is "m8" . They are NOT created dynamically.

    the children are even organized in layers alphabetically.

    i've already tried:

    Code:
    //			for each (var item:MovieClip in menu)
    //			{
    //				menu_items.push(item);
    //			    
    //			}
    
    //                      menu_items.sort();
                             // this sort in a different order , but still unordered.
    
    
    			for (var i:int; i < menu.numChildren; i++)
    			{
    				var item:String = "m" + String(i);
    				trace (item);   // ok it should work....
    
    //				menu_items[i] = menu.getChildByName(item);
    //                             didn´t worked.
    
    				trace (menu.getChildByName("m1").name);
                                    // ok, that traces "m1"
     			}
    
    			trace(menu_items[0].name);
    			trace(menu_items[1].name);
    			trace(menu_items[2].name);
    			trace(menu_items[3].name);
                            // always in the wrong order......
    HELP!!!!

  2. #2
    Member
    Join Date
    Jul 2009
    Location
    Florianópolis
    Posts
    81
    solved it.

    menu_items[i] = menu.getChildAt(i);

    =D

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center