Things you have to do to program a button in AS 3.0
1. You need to DECLARE a function with what the button is going to do, 2. You need to name the instance of the button, so AS3 can find it 3. You need to DECLARE an event listener (addEventListener), connected in the code to the button-instance-name, using dot syntax). What state will trigger an action (ROLLOVER, CLICK...)This is called MouseEvent, |
Code for a button named play_btn, that needs to move the timeline to frame n 5 and let it play when the user clicks on it,
function goNow(event:MouseEvent) play_btn.addEventListener(MouseEvent.CLICK, goNow);
|
Mouse Events are always refered to in AS3 in Uppercase. The events defined for the MouseEvent class are:
CLICK,
DOUBLE_CLICK
MOUSE_OVER
MOUSE_DOWN
MOUSE_UP
MOUSE_MOVE
MOUSE_OUT
MOUSE_WHEEL
ROLL_OVER
ROLL_OUT
Most of the actions we will be working with in this class are going to be Ttimeline navigation-commands.
(commands that move the playhead across the timeline).
There are a number of simple to use functions already made by Flash to navigate the timeline.
Those ready-made functions are called METHODS.
Most common METHODS | Don't need a parameter | stop(); play(); nextFrame(); previousFrame(); |
Need a parameter (information written inside the parenthesis) |
gotoAndStop(); |