Interactive movies change based upon the viewer’s actions. To create an interactive movie you need buttons to detect when a user wants to change a what is occurring. There are several different ways to do this. Usually from using a button or a movie clip and determining if a user clicked on it.
The button is a special type of symbol. The button only has 4 frames. Each of the first three frame represents a state of the button. The final frame is used for a special case.
- Up State – the normal view
- Over State – when the mouse is over it
- Down State – when the user is over and has pressed the button
- Hit State – the click-able area of the button
You can create invisible buttons by hiding the first frame (have nothing on the up state) but have a hit state defined – so Flash can detect when the user rolls over an area.
Buttons can have layers in their time line – which is always nice. You can include animation in your button by placing a Movie Clip in the time line of the button.
Want to learn more about buttons, check out the in depth details about buttons in Flash.
Variable – a named placeholder for specific information. Think of a bread box. It holds bread, but is not bread.
Keyword – a reserved word for Actionscript. Flash won’t let you name your variable one of these keywords.
Function – a group of statements which can be run by calling the function name.
Argument – value(s) passed to a function. It gives the function more information to run and do specific tasks
Objects – abstract types of data
Methods – functions attached to objects
Properties – describe an object
Comments – a way to write notes to yourself in the script, to remind you of what you are doing. These are ignored by flash.
Using Actionscript for Internal Navigation
Event handlers listen for events occurring during the playing of a Flash movie. You will need to assign an event listener to a navigation button. That will call a custom function you write, and in there, you will issue a command to move the playback head to a different part of your Flash movie.
You can use gotoAndPlay/gotoAndStop and pass a frame number, or a frame label as an argument. However, numbers may move as you add/remove animation, but your code won’t update.
gotoAndStop(5); // the playback head moves to frame 5, // it then stops gotoAndPlay(15); // the playback head moves to frame 15, // it then keeps on playing
Labels move with your frames as you add/remove them. They can also work better as they can provide meaningful information about the frame you are moving to.
Note: Labels are case sensitive. They also must be in quotes, or Actionscript will treat it like a variable.