<classwork>

Buttons

The most straight forward way to add interactivity to your movie is with buttons. Buttons can be any shape, they can be animating, they can be invisible (great for keystroke-pressing a key to make something happen), they can have sound in them.

A button has four states
Up: The state your button is in when no interaction is occurring.
Over: The state the button is in when the mouse is over it.
Down: The state the button is in when the user presses on it.
Hit: This is not visible. This defines the area of the button that will be active.


Programming Buttons

You can attach event handlers directly to a button using the on() handlers. The on() handler handles button events.

To use an on() handler, attach it directly to an instance of a button on the Stage and specify the event you want to handle for that instance. For example, the following on() event handler executes whenever the user clicks the button that the handler is attached to.

on(press) {
trace("Thanks for pressing me.");
}

You can specify two or more events for each on() handler, separated by commas. The ActionScript in a handler executes when either of the events specified by the handler occurs. For example, the following on() handler attached to a button executes whenever the mouse rolls over out of the button.

on(rollOver, rollOut) {
trace("You rolled over, or rolled out");
}


NOTE: FILE IS BROKEN!!!

download the the go to tutorial to learn more about buttons (file name: 6goto.fla)
right click on the file (control-click for Mac) and select to download to your drive.


Another example of buttons going to and stopping/playing frames, timelines, and audio:

download the this file to learn more about buttons (file name: goto_stop_frame.fla)
right click on the file (control-click for Mac) and select to download to your drive.