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