Button staying on (AS3)
I have a menu with five items in it. Every menu item is two words, both grey, and is a button. When the button is rolled over the second word goes red. So far, so easy. However, when the button is clicked and sends the timeline to the correct frame label, I want that button to stay in its grey/red state, in other words its rollover state. Is it possible to label a frame inside a button timeline, in the same way as one would in a movie clip, and then send the play head to that?
Or maybe there are some really easy and obvious solutions that I haven't seen that I would be grateful to hear about.
No, you can't do this with a Button. You need to use a MovieClip instead. I rarely use Buttons because they are so limited. Instead, I use MovieClips AS buttons.
To do this, make a MovieClip with three child MovieClips nested inside it. In other words...
Make the child clips look like whatever you want the "button" to look like in its various states, and give the children the instance names up, over and down (all lower case). That last step is very important for what follows.
Let's say you have three "buttons" made like this (each with three child MovieClips nested inside them). Let's also say that these "buttons" have the instance names button1, button2, and button3. To make them work like Buttons, add this code to whatever frame your buttons first appear in:
Now, any time you want the button to be stuck in its down state, you just call the showState function, e.g. showState(button3, DOWN);
If you want to lock a button into its currentState, call deactivateStateChanges(), e.g. deactivateStateChanges( button2 );
If you want to keep a button in it's down state, call both functions, e.g. ...
showState( button1, DOWN );
deactivateStateChanges( button1 );
If you later want button1 to show state changes again, do this...
showState( button1, UP );
activateStateChanges( button1 );
I hope this helps.
Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer, Zeitbyte.com