A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple question about arrays

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    13

    Simple question about arrays

    var buttonList:Array = new Array('button1', 'button2');
    trace(buttonList);
    buttonList.buttonMode = true




    How do I declare this so that all my buttons are actually true??
    When I trace the list I get the result I'm expecting but I want the final result to be:
    button1.buttonMode = true
    button2.buttonMode = true

    s'not working as it is.
    :-(

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    Code:
    for each(var b:String in buttonList) this[b].buttonMode = true;
    Or you can be even more efficient by using an Array of objects, instead of an Array of Strings:
    Code:
    var buttonList:Array = new Array(button1, button2);
    for each(var b:Sprite in buttonList) b.buttonMode = true;
    Last edited by MyFriendIsATaco; 11-28-2009 at 01:56 PM.

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