PDA

View Full Version : Controling Buttons through script


random_goblin
07-30-2001, 07:07 PM
Does action script provide any means of targeting an instance of a button?

I have a set of buttons displaying dynamic text, updated from a txt file. I need to hide/make inactive the button if the text content for that button is null.

Short of putting all button hidden/not hidden combinations into a movie and then calling the appropriate frame, or placing each button in it own movie clip, I can't see how to do this.

Is there a more elegant method?

thanks in advance...

Immulsifier
07-30-2001, 11:11 PM
Well you could make it inactive by using something like this. Say the variable in your text file is called var1.


on (release) {
if (var1 = "") {
stop ();
} else {
gotoandPlay etc
}
}


That method would show the button all the time but would make it inactive if the variable returned a null value.

To make the button disappear if the variable didnt exist you would need to put it into a movie clip and have some similar code on the main timeline which checked the varaible and then showed the movie clip if it was not equal to nothing.

Immy

Jesse
07-31-2001, 04:44 AM
I would put the buttons into 1 MC each and hide or show the MCs depending on your variables. Buttons cannot have setProperty performed on them, although they are actually allocated instances in Flash 5 (if you view in the debugging environment).

random_goblin
07-31-2001, 10:21 AM
Thanks,
I thought the movie clip approach was going to be the solution, just seems a little clumsy somehow.
Hopefully setProperty will be a feature of buttons and graphics in Flash6, or will we then just be calling them sprites ?