A couple months ago, Mike Chambers released an EventProxy class, which served to make delegating EventDispatcher events simpler. At the time, I meant to release my own EventProxy class with some extra functionality, but it slipped my mind until today when Phil reminded me of it.
My EventDispatcher works almost exactly the same as Mike's, with 2 differences:
You can download EventProxy by clicking here. It should be placed in the com.gskinner.events package.
You can see a brief usage example below. For a full description of how to use EventProxy, please see Mike's post on the subject.
My EventDispatcher works almost exactly the same as Mike's, with 2 differences:
- It calls handleEvent on its target, as well as the specified function.
- It has an enabled property, that lets you temporarily disable the proxy
You can download EventProxy by clicking here. It should be placed in the com.gskinner.events package.
You can see a brief usage example below. For a full description of how to use EventProxy, please see Mike's post on the subject.
// import the EventProxy so we can refer to it by name: import com.gskinner.events.EventProxy; // create an instance of EventProxy, and tell it to call // doStuff in this scope when triggered: clickEventProxy:EventProxy = new EventProxy(this,"doStuff"); // register the EventProxy to listen for click events // from the button: myPushButton.addEventListener("click",clickEventProxy); // this function will be called when the button is clicked. function doStuff(p_evtObj:Object):Void { trace("button clicked"); // stop it from firing again for now: clickEventProxy.enabled = false; }
Comments (7)
This is completely separate from GDispatcher, right?
Posted by: Mike Britton at May 7, 2004 12:49 PMURL:
hi,can you tell me what's the meaning of
Posted by: frank at June 29, 2004 08:57 PM"clickEventProxy:EventProxy = new EventProxy(this,"doStuff");
".
because the Flash tell me "Syntax error".And i changed it to "clickEventProxy= new EventProxy(this,"doStuff");
".Everything gose well.I just want to know why.I'm from china,so my english is so poor:)
URL: http://www.2solo.net
"because the Flash tell me "Syntax error".And i changed it to "clickEventProxy= new EventProxy(this,"doStuff");"
Are you using Flash MX and not MX 2004, as declaring a property in this way is ActionScript 2.0, using this code in Flash MX will cause an error (like you have recieved) as it's ActionScript 1.0.
Posted by: Paul at September 29, 2004 09:38 AMURL: http://www.thedustroom.net
this is my email: www.ashen23_rose@yahoo.com
pls sent me a code and steps in hoe to make a Demo out of flash mx.
thanx
Posted by: rhea at May 12, 2005 10:00 PMAshen
URL:
this is my email: www.ashen23_rose@yahoo.com
pls sent me a code and steps in hoe to make a Demo out of flash mx.
thanx....
Ashen
Posted by: ashen at May 12, 2005 10:02 PMURL:
pls sent me a code and steps in how to make a Demo out of flash mx.
thanx....
Posted by: rhea at May 12, 2005 10:04 PMAshen
this is my email: www.ashen23_rose@yahoo.com
URL:
hey G, you may want to update the zip with your newer version, line 23 seems outdated, it is missing the check for "undefined"
listener[(functionName!=undefined) ? functionName : p_evtObj.type](p_evtObj);
Posted by: Ivan at January 6, 2006 08:27 PMCheers
URL: http://www.ivantodorov.com