Re: [Flashcoders] Event Handling in ActionScript 3

2008-01-28 Thread Guybrush Threepwood
Thank you again!
I can't think of a reason not to extend EventDispatcher. I think most
classes in AS3 seem to be a subclass of it.
I'm sure there must be cases where you can't just extend EventDispatcher. I
just can't think of one now.

Thanks!
Guybrush
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Event Handling in ActionScript 3

2008-01-27 Thread Guybrush Threepwood
Hans/JC/Glen,Thanks for your great advice.

I understand the new event mechanism is far better than the callback thing I
used to do.
I think I'll do as you say. Just wanted to know if it was possible at all.

Any URLs on how to implement IEventDispatcher? I'm not used to implement
interfaces. I'm used to extend classes (using inheritance) but not sure how
to implement interfaces in AS3.

Thanks!!
Guybrush

PS: How do you know I'm not in Monkey Island?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Event Handling in ActionScript 3

2008-01-26 Thread Guybrush Threepwood
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