How do I create an event listener in AS3 that is called when a function is complete? Example:

doSomething();
doSomething.addEventListener(Event.COMPLETE, onComplete);
public function doSomething():void {
blah blah blah...
}
public function onComplete():void {
blah blah blah...
}

I know the code doesnt work but thats what I am trying to accomplish.

1 answer

0
points

It's been a while since I've had to work in Flash but I believe you could do something like this in your doSomething function:

public function doSomething():void {
    //do whatever
    dispatchEvent(new Event(Event.COMPLETE));
}
Answered almost 7 years ago by Matt Milburn