With event dispatching, multiple objects can register themselves to listen to 
the event. With the way below, there is no way multiple objects can react to 
onBallPress as you cannot do delegate chaining in Actionscript.


Patrick Matte <[EMAIL PROTECTED]> wrote: I dont see exactly why use for the 
event dispatcher.
Wouldn't this be good as well ?


// on timeline

import Ball2.as;
import mx.utils.Delegate;

var myBall:Ball2 = new Ball2();

myBall.onBallPress = Delegate.create(this,onBallPress);
myBall.addEvents();

function onBallPress():Void {
 trace("onBallPress");
}


// ball class

import mx.utils.Delegate;
class Ball2 {

 public var onBallPress:Function;
 private var aBall:MovieClip;

 public function Ball2 () {
  // create a ball MC
  aBall = 
_level0.createEmptyMovieClip('testBall',_level0.getNextHighestDepth()  );

  // draw ball
  aBall._x = 100;
  aBall._y = 100;
  aBall.lineStyle(20, 0xff0000, 100);
  aBall.lineTo(0,.2);
 }

 public function addEvents():Void{
  aBall.onPress = Delegate.create(this,onBallPress);
 }

}

_______________________________________________
[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


                
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
                
---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.
_______________________________________________
[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

Reply via email to