Hi, If you dont like the as3 event mechanism, you can write your own, but looking at your code, there are a number of things I wouldn't do: - setting local variables on the activation stack, it leads to memory waste - executing the asynchronoustask before setting the callback handlers - prepending everything with m - using simple strings as type instead of static public event types - using the callback mechanism (overriding the onTasketc method) combined with the event types and required params
So to be honest I wouldnt port this way of working to AS3 , I'd take it as an opportunity to do it better this time around. We're not on monkey island you know;-) greetz JC On Sat, Jan 26, 2008 at 3:48 PM, Guybrush Threepwood < [EMAIL PROTECTED]> wrote: > Hello. I'm new to AS3. I'm using Flash CS3.I've been reading recent posts > about event handling, EventDispatcher, and the Delegate class which used > in > AS2. > I've read the documentation about the EventDispatcher class, and learnt > how > to use it in Flash. > > How ever I can't seem to fin a way to do what I used to do in AS2. I > didn't > use Delegate. I did something like this: > > import org.guybrush.MySuperFeaturedClass; > class MyWrapperClass { > var mySuperObject:MySuperFeaturedClass; > function whatever( n:String ):void{ > this.mySuperObject = new MySuperFeaturedClass(); > this.mySuperObject.mDoSomeAsynchronousTask( n ); > var self:MyWrapperClass = this; > *this.mySuperObject.mOnTaskCompleted = function ( type:String, > arg2:String ){* > switch(type){ > case "one": > trace("ok, task returned 'one'"); > break; > case "red": > trace("look! task returned 'red'"); > break; > case "bananas": > trace("wel... task returned 'bananas'"); > break; > default: > trace("oh! task returned " + type); > break; > } > }; > } > } > > I know how to achieve the same with addEventListener. The thing is, doing > it > that way I always need to create handling function for each event I'm > "registering". And the other disadvantage is that when the class I'm > consuming is a custom class coded by my self, I need to either make it a > subclass of EventDispatcher, or implement its interface somehow. > > So basically, my question is: *"how can I do what I used to to in AS2, now > in AS3?"* > > > Thanks in advance for any replies, > Guybrush > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders