-
Dispatch Events in AS2.0
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);
}
}
}
-
Is there a question here? Also, you can use a [CODE] wrap to help with posting code. If you want an example then the quote button should help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|