A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Disabling multiple buttons

  1. #1
    Swollen Member jhbiddle's Avatar
    Join Date
    Jan 2001
    Location
    Cambridge, England
    Posts
    141

    Disabling multiple buttons

    Hi,
    I am wanting to replace the following instruction with something a little smarter;

    _root.links.link1.enabled = false;
    _root.links.link2.enabled = false;
    _root.links.link3.enabled = false;
    _root.links.link4.enabled = false;
    etc...

    Can I select multiple? eg: ...link(1,2,3,4).enab...
    Can I do this over a range? eg: ...link(1 to 4).enab...
    Can I select all? eg: ...link(N).enab...

    I know this is simple, but I am just not quite sure how to do this. Any help would be totally appreciated, as I am learning the general principles as much as solving this particular problem.

    Many thanks, guys.
    JB
    Feet on the ground, eyes to the stars

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    you can use eval() or array notation inside a for() loop:
    code:

    for (var i = 1; i <= 5; i++) {
    _root.links["link" + i].enabled = false;
    // or
    eval("_root.links.link" + i).enabled = false;
    }


  3. #3
    FK Slacker
    Join Date
    Jun 2000
    Location
    vancouver
    Posts
    3,208
    You can use a for loop to cycle through your buttons:

    var buttonCount=4;

    for(var b=1;b<=buttonCount;b++){
    _root.links["link"+b].enabled=false;
    }

    Should do it...

    K.

  4. #4
    Swollen Member jhbiddle's Avatar
    Join Date
    Jan 2001
    Location
    Cambridge, England
    Posts
    141
    Thanks alot!

    I will go through and discect what you recommend. I'll give it a try and post a reply in case anyone else finds it useful.

    Many thanks again
    Feet on the ground, eyes to the stars

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