In MXML, click="Foo(2)" really generates the following code:

 

private function btnFoo_clickHandler(event:MouseEvent):void

{

            Foo(2);

}

btnFoo.addEventListener(MouseEvent.CLICK, btnFoo_clickHandler);

 

What you tried to do in AS was set the listener to be the result of a
call to Foo(2)

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Jason The Saj
Sent: Wednesday, April 16, 2008 12:13 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Click Lite: The right click now. But not now?

 

Why does click work here?

<mx:Button id="btnFoo" label="Foo x 2" click="Foo(2)"/>

But not here?

btnFoo.addEventListener(MouseEvent.CLICK,Foo(2));

Now, it's obviously Adobe has coded the button component to allow for
arguments to be passed via the click parameter. But we're not given
that same privilege when using just AS3.

But obviously, they must have already coded this functionality. I'd
rather not have to re-invent the horse. Any answers?

 

Reply via email to