Event handlers orchestrate your movies' interactivity by controlling when scripts are triggered. They provide a "when" to a script so that it executes only when something specific occurs. Every script in your movie is triggered by an event a user rolling over a button or pressing a key, your movie's timeline reaching a certain frame, and so on.

In ActionScript, event handlers (with the exception of frame events) usually represent the first lines in any script. For example:

 When this happens (eventHandler) {    do this;    do this;  } 

Frame events occur when the timeline reaches a frame that contains a script. When placing a script on a frame, you don't need to identify a frame event to trigger that script because the timeline reaching the frame is enough to cause it to execute. Thus, if placed in a frame, the above script would look like this:

 do this;  do this; 

The better you understand event handlers, the more control you'll have over your user's experience. By using event handlers properly, you can create immersive environments the user will feel a part of.

Many computer programs allow users to accomplish tasks by letting them drag and drop items on the screen, resize windows, make adjustments with sliders, and create artistic masterpieces using "virtual" art tools all modes of interaction determined by the way the software has been programmed to deal with various events (mouse presses, mouse movements, keyboard input, and so on).

Macromedia Flash MX ActionScripting Advanced. Training from the Source
Macromedia Flash MX ActionScripting: Advanced Training from the Source
ISBN: 0201770229
EAN: 2147483647
Year: 2002
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net