Downside of not going through event dispatching is that the argument 
(e:MouseEvent) will not always be there.
So in your function you'll have to take that into consideration if you're 
relying on it:

private function myClickHandler(e:MouseEvent):void {
    e.currentTarget // etc..
}

Will throw an error if the argument is null.

Passing a "dummy" mouse event will have the event point to the "wrong" 
currentTarget.
And so on..

Easiest way is to just dispatch the event on the button as I previously posted 
(version 1).

----- Original Message ----- From: "Steven Sacks" <[EMAIL PROTECTED]>
To: "Flash Coders List" <[email protected]>
Sent: Sunday, April 06, 2008 5:06 AM
Subject: Re: [Flashcoders] Calling Listener Functions


I disagree with this approach. It's unnecessary and makes code less manageable. It's cleaner to set the argument as optional (event = null) than write another subroutine.


Matt S. wrote:
You might want to separate the functions, so you  would have
myFunction(), which you could call from anywhere, and myClickHandler,
which would handle the mouse event specifically. So:

fancyButton.addEventListener(MouseEvent.CLICK, myClickHandler);

private function myClickHandler(e:MouseEvent):void {
    myFunction();
}

private function myFunction():void{
      //blah blah...
}

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to