Schemaphic Systems Blog

Sharing experiences in Flash, Flex and AIR

Dispatch Events in AS2.0

leave a comment »

function onComponentClickHandler( o:Object ):Void{
trace(“component clicked”);
//do something here
}
component.addEventListener(“click”, onComponentClickHandler);

//component class – Component.as
import mx.events.EventDispatcher;
class com.Component extends MovieClip
{
public var addEventListener:Function; //declaring the function to access addEventListener of MovieClip

public function Component () {
EventDispatcher.initialize(this);
this.onRelease = function() {
//creating the event object
var eventObj:Object = new Object();
eventObj.type = “click”; // event type
eventObj.target = this; // event target
dispatchEvent(eventObj);
}
}
}

Advertisements

Written by Deepanjan Das

July 19, 2010 at 9:53 PM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: