Technically speaking, you can instantiate a bogus MouseEvent to call the
function:

myFunction(new MouseEvent(MouseEvent.CLICK));

However, I only mention this to be complete in directly answering the
question. I would think that Matt's suggestion is the more appropriate.

-jonathan


On Sat, Apr 5, 2008 at 9:16 PM, Matt S. <[EMAIL PROTECTED]> wrote:

> On Sat, Apr 5, 2008 at 8:58 PM, Omar Fouad <[EMAIL PROTECTED]>
> wrote:
> > Hi,
> >  I've got a function that is called when a listener listens an event
> like:
> >
> >  fancyButton.addEventListener(MouseEvent.CLICK, myFunction);
> >
> >  private function myFunction(e:MouseEvent):void {
> >    // statements...
> >  }
> >
> >  If I try to call myFunction using myFunction() , the compiler throws me
> an
> >  error, saying that the function expects an argument. At this point how
> >  should I call this function without dispatching the MouseEvent Event??
> >
>
> 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
>



-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to