all groups > flash actionscript > august 2006 >
You're in the

flash actionscript

group:

Is there an easy way to disable all buttons



Is there an easy way to disable all buttons Josh Pratt
8/23/2006 9:00:25 PM
flash actionscript: When I click on a button that I have, is there an easy way to disable all
buttons on a specified level?

I've got a button on that loads a swf into _level25. I'd like to disable
everything clickable on _level5 and _level20

Is this easily done? I tried this: _level20.enabled = false; but that
method doesn't work... Any suggestions?
Re: Is there an easy way to disable all buttons Rothrock
8/23/2006 9:05:29 PM
I take it you need to keep seeing those levels? If not:

_level5.visible=false

Should do it.
Re: Is there an easy way to disable all buttons abeall
8/23/2006 9:10:40 PM
Otherwise, you might try using a for.. in loop:

for(var mc in _level5){
if(_level5[mc].enabled){
_level5[mc].enabled = false;
}
}
for(var mc in _level20){
if(_level20[mc].enabled){
_level20[mc].enabled = false;
}
}

or combine the two:
var levels = [_level0,_level5,_level20];
for(var lev in levels){
for(var mc in levels[lev]){
if(levels[lev][mc].enabled){
levels[lev][mc].enabled = false;
}
}
}
Re: Is there an easy way to disable all buttons Josh Pratt
8/23/2006 9:21:36 PM
I tried your code like this:

var levels = [_level5,_level20];
for(var lev in levels){
for(var mc in levels[lev]){
if(levels[lev][mc].enabled){
levels[lev][mc].enabled = false;
}
}
}

And it didn't work...
Re: Is there an easy way to disable all buttons abeall
8/23/2006 9:37:02 PM
Re: Is there an easy way to disable all buttons abeall
8/24/2006 3:00:35 PM
No, I mean put some buttons on _level0 and see if that code works. Reason I ask
is because it works for me on _level0, but I haven't tested on other levels. I
think it's very unlikely it would work on _level0 and not other _levels, so by
asking you to try it on _level0 I know that if it does not work for you on
_level0, while it does work for me on _level0, there is some other factor.
Re: Is there an easy way to disable all buttons abeall
8/24/2006 4:14:55 PM
[quoted text, click to view]
Interesting, but how come it works on _level0 to create an actual reference in
the array? Is it because the _levels don't exist at the creation time of the
array?
Re: Is there an easy way to disable all buttons Josh Pratt
8/24/2006 4:30:37 PM
I just broke down and created a couple functions on _level0 to call at anytime
that disables all the buttons specifically. There are about 12 buttons that
get disabled and reenabled... If ever I add a button, I'll just add the extra
code. Probably not super efficient, but it works for now.
Re: Is there an easy way to disable all buttons kglad
8/24/2006 7:54:18 PM
yes, your _levels must be instantiated before trying to reference them. if you
define your array after all the _levels that it contains are instantiated,
you'll have no problems.

also josh, you don't want to execute the disabling code (using strings or
direct references to existing _levels) until all the movieclips/buttons that
you want to disable exist. after that there should be no problem.
Re: Is there an easy way to disable all buttons uamg
8/25/2006 12:00:00 AM
I find it easiest to just cover everything with an invisible button for which
the handcursor is disabled.

Here's my way to disable all rollovers and clicks:

1. Create a button with a rectangel in its hit state and nothing in its other
states. Let's call it clickTrapButton.
2. Place it above everything on the level you want to disable.
3. Scale the button to the same size as the stage (or the area you want to
disable)
4. Disable the hand cursor like this:
clickTrapButton.useHandCursor = false;
5. Initially you should set clickTrapButton._visible = false so that your
buttons underneath are enabled.
6. Whenever you want to disable the specific level, just set
clickTrapButton._visible = true;

Of course, if you only want to disable button pressing but still want the
rollovers to work, this method won't work.

AddThis Social Bookmark Button