|
|||
| week 05c - exercises, enterframe event, flags, movieclip states, events | |||
event handlers: |
react to the world By now you've had some experience using event handlers such as "on (release)" to enable your scripts to react to spontaneous events. To review, event handlers tell Flash to wait for a specific kind of event, and every time that event occurs, run the code block associated with the handler. For example, consider an event handler such as the following:
This event handler tells Flash to wait for a mouse release associated with that particular button or movieClip. When the event is received, the code is run to rotate that object by modifying its _rotation property.
|
|||||||||||||||||||||
| button events : | events for the current object Whenever you use the "on" event handler (so-called button events), you are telling Flash to only watch for events related to that specific object. So if "on (release)" is used, only mouse releases for that object are run, while other objects with "on (release)" only respond to events associated with the other object. Button events may be used in buttons and movieClips.
|
|||||||||||||||||||||
| clip events : | movieClip events The other kind of event available in ActionScript is defined with "onClipEvent" and are called movieClip events, and may only be used in movieClips. Some clip events are specific to the particular movieClip object, while other events watched are global to the whole movie. For example, the following code only runs when a particular movieClip first appears on stage:
Other clip events are general to the whole movie (not any specific object), and any movieClip with an event handler for these events will respond when the general event occurs. For example, if several movieClips on the stage have an event defined for the mouseMove event, when the user moves the mouse, all movieClips that have an "onClipEvent (mouseMove)" will run their code.
One of the mose useful of these general events is the enterFrame clip event. You can use this event to cause a movieClip to run some code continually. The code will be run once per frame of the movie. So if a movie is set to 12 frames, any clip event on any movieClip will run 12 times per second. enterFrame events occur regardless of current play or stop status of the main timeline or any movieClip timeline.
|
|||||||||||||||||||||
| button events : | list
|
|||||||||||||||||||||
| clip events : | list
|
| all materials on this web site © copyright 2004, Philip van Allen |
top |