describeType method with custom events
Posted in Flash by Flash CS3 and Flash CS4 tutorials on the 10-18-2009We saw long ago how to create custom events.
In this tutorial we explore custom events and the method describeType of Actionscript 3.0 utils package.
This method wants an object as a parameter and returns an XML format with the full description of the object except for the static properties.
In can check the XML format output that shows the method describeType at the following URL:
In this tutorial we are dispatching two types of events ( Timer and Object) and then the class that is listening for these events will use the method describeType to retrieve the data type of the event and so according to the separate actions to be taken.
This tutorial is expanded in this way:
- A main.fla file where there is an instance of a ComboBox and TextArea.
- The Document Class (Main.as) that populates the ComboBox and dispatching custom events.
- A class called CustomEvents that extends the Event class and that, as the name implies, contains static constants that are nothing more than custom events names.
- A class called MyDispatcher extending the EventDispatcher class.
- A class called DrawingClip that listens for events that implements an instance of MyDispatcher and that property is listening the events dispatched by the Document Class (Main.as). Depending on the type of event, DrawingClip perform actions.
In practice:
- We need a class that extends Event that serves as "warehouse" containing the names of custom events (CustomEvents.as).
- Then another class that simply extends EventDispatcher (MyDispatcher) which the created instance of that class should be in the class that will listen for events and then perform the actions (in our case is DrawingClip).
- About dispatching events? In this case the Document Class (Main.as) dispatches them by taking from CustomEvents.as. Such as when we dispatch the MouseEvent.MOUSE_DOWN event that we take the name from the MouseEvent class.
Let’s see the example to better understand.
Tags: custom events, describeType, Event, EventDispatcher, eventsRelated posts
- No related posts.

Responses to “describeType method with custom events”