Monday, January 10, 2011

Capturing Events in Flash : Part I - In-Built Events

What is an Event?An event is any specific change/occurrence while the flash application is running. This event can be a caused by any external device, or by completion of a particular step internally by the movie. Following are few in-built event classes in AS3

1.  Event
2.  KeyboardEvent
3.  MouseEvent


Every event has a target associated with it, such that the event occurs on any change done to that particular target.

For example, if we click any button, then that button is the target of that MouseEevent.

Further, every target has a type and name associated with it.

The event target type can be captured as any Button, Movieclip or any other object.
The event target name is the name of the object instance as given in the "fla".

AS3 library provides many in-built events. It is difficult to cover them all in one-go, so let us check the most important ones, that we use in our day-to-day applications.

Mouse Events: Available at flash.events.MouseEvent
10 different operations can be done using the mouse, namely:

1.  CLICK --> associated with any mouse click (down + up) on any object
2.  DOUBLE_CLICK --> associated with any double mouse click (down + up) on any object
3.  MOUSE_DOWN --> associated with any mouse click (down) on any object
4.  MOUSE_MOVE --> associated with any mouse move on any object
5.  MOUSE_OUT --> associated with any mouse out (away from) on any object
6.  MOUSE_OVER --> associated with any mouse kept over on any object
7.  MOUSE_UP --> associated with any mouse click (down + up) on any object
8.  MOUSE_WHEEL --> associated with any mouse scroll on any object
9.  ROLL_OUT --> associated with any mouse out on any particular child of an object
10. ROLL_OVER --> associated with any mouse over on any particular child of an object

KeyBoard Events: Available at flash.events.KeyboardEvent
2 different operations can be done using the keyboard, namely:

1.  KEY_UP --> associated with the released pressed key.
2.  KEY_DOWN --> associated with the pressed key.

Other Events: Available at flash.events.Event
Commonly used events are as follows:
1.  ACTIVATE --> Dispatched when Flash Player or application gains operating system focus and becomes active
2.  ADDED --> Dispatched when the listening displayobject is added to another display object (whether or not in placed in stage
3.  ADDED_TO_STAGE --> Dispatched when the listening displayobject is added to the stage (timeline)
4.  CANCEL --> Dispatched when a file upload or download is canceled through the file-browsing dialog box by the user
5.  CHANGE --> Dispatched when children of any object deal with updating themselves
6.  CLOSE --> Dispatched when the socket connection is closed
7.  COMPLETE --> Dispatched when swf data has loaded successfully
8.  CONNECT --> Dispatched when the socket connection is established
9.  DEACTIVATE --> Dispatched when Flash Player loses operating system focus and is becoming inactive.
10. ENTER_FRAME --> Dispatched every time the playhead enters a new frame and is tied to the frame rate being run by the Flash Player
11. FULLSCREEN --> Dispatched when full-screen mode is turned on or off
12. ID3 --> Dispatched by a Sound object when ID3 data is available for an MP3 sound
13. INIT --> Dispatched when the properties and methods of a loaded SWF file are accessible
14. MOUSE_LEAVE --> Dispatched if you release the mouse button outside the stage
15. OPEN --> Dispatched when an upload or download operation starts
16. REMOVED --> Dispatched whenever a display object is removed from the display list
17. REMOVED_FROM_STAGE --> Dispatched whenever a display object is removed from the stage
18. RENDER --> Dispatched just before the screen is rendered, giving all listening objects the chance to update
19. RESIZE --> Dispatched when the flash window is re-sized, and the parent object handles the re-sizing of all its children
20. SCROLL --> Dispatched whenever any area/field is scrolled (mostly used with text areas)
21. SELECT --> Dispatched when the user selects one or more files to upload from the file-browsing dialog box
22. SOUND_COMPLETE -->Dispatched when the sound finishes playing
23. TAB_CHILDREN_CHANGE --> Dispatched when the value of the object's tabChildren flag changes
24. TAB_ENABLED_CHANGE --> Dispatched when the object's tabEnabled flag changes
25. TAB_INDEX_CHANGE --> Dispatched when the value of the object's tabIndex property changes
26. UNLOAD --> Dispatched when any movie is unloaded

No comments:

Post a Comment