I’m still wondering which method is the best use:
Event Dispatcher:
package
{
import flash.events.EventDispatcher;
public class Test
{
public var onMyEvent:Function;
public function Test()
{
dispatchEvent(new Event("MyEvent"));
if (onMyEvent!=null) onMyEvent();
}
}
}
Event Receiver:
var test:Test;
test.addEventListener("MyEvent", myEvent);
private function myEvent(event:Event):void
{
// This event invoked by dispatchEvent
}
test.onMyEvent = function()
{
// this event invoked by a function call
}
test = new Test();
Which method is more effective and faster?