-
Swollen Member
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
-
Registered User
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;
}
-
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.
-
Swollen Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|