On 2/4/07, Stephen Ford <[EMAIL PROTECTED]> wrote:
Which do you prefer:oThis:Object = this;mcClear.onRelease = function():Void{
oThis.clearForm();}ormcClear.onRelease = Delegate.create(this, clearForm);Also,
anyone please let me know if my code formatting doesn't work (i.e: shouldn't be
using hotmail to post)Thank
I prefer Delegate, since it's less code. Thankfully, in AS3 you can
just use function references (no loss of scope).
Sometimes (especially if I ever need to use
EventDispatcher.removeEventListener) I'll create a Delegate as a
private variable.
import mx.utils.Delegate;
import mx.events.EventDispatcher;
class MyClass extends Object {
public function MyClass() {
super();
_doSomething = Delegate.create(this, doSomething);
}
public function listenTo(dispatcher:EventDispatcher):Void {
dispatcher.addEventListener("eventType", _doSomething);
}
public function stopListeningTo(dispatcher:EventDispatcher):Void {
dispatcher.removeEventListener("eventType", _doSomething);
}
private function doSomething(event:Object):Void {
// Do something!
}
}
--
T. Michael Keesey
Director of Technology
Exopolis, Inc.
2894 Rowena Avenue Ste. B
Los Angeles, California 90039
--
The Dinosauricon: http://dino.lm.com
Parry & Carney: http://parryandcarney.com
ISPN Forum: http://www.phylonames.org/forum/
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com