RE: [flexcoders] Handler functions convention
if you subscribe to the event using ActionScript, not the mxml handler sugar, then you'll always get the event. An MXML event attribute like click=trace(event.target) just autogenerates an event handler that looks like function clickHandler(event:MouseEvent):void { trace(event.target); } The attribute value is code that becomes the body of the handler. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Mike Chang Sent: Saturday, April 03, 2010 10:47 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Handler functions convention Thanks Gabriel. Mike 2010/4/3 gabriel montagné gabr...@rojored.commailto:gabr...@rojored.com On 03/04/2010, Mike Chang mik...@gmail.commailto:mikecc%40gmail.com wrote: I noticed in many examples on the web handler functions mostly have a parameter event, even though the event isn't used (such as even.target). I'm wondering if there's a reason for this convention. I'd say it's up to you, but if you subscribe to the event using ActionScript, not the mxml handler sugar, then you'll always get the event. I have to pass a null in case it isn't triggered by the event, which seems pretty cumbersome. Perhaps you could use defaults in the handler, something like login_clickHandler(event:MouseEvent = null) Gabriel -- gabriel montagné láscaris comneno http://rojored.com +44 (0) 7500 709 209
Re: [flexcoders] Handler functions convention
On 5 April 2010 19:25, Gordon Smith gosm...@adobe.com wrote: ... The attribute value is code that becomes the body of the handler. Cool. This is great to know! Thanks, Gabriel -- gabriel montagné láscaris comneno http://rojored.com +44 (0) 7500 709 209
[flexcoders] Handler functions convention
Hi, I noticed in many examples on the web handler functions mostly have a parameter event, even though the event isn't used (such as even.target). I'm wondering if there's a reason for this convention. I have to pass a null in case it isn't triggered by the event, which seems pretty cumbersome. Mike
Re: [flexcoders] Handler functions convention
On 03/04/2010, Mike Chang mik...@gmail.com wrote: I noticed in many examples on the web handler functions mostly have a parameter event, even though the event isn't used (such as even.target). I'm wondering if there's a reason for this convention. I'd say it's up to you, but if you subscribe to the event using ActionScript, not the mxml handler sugar, then you'll always get the event. I have to pass a null in case it isn't triggered by the event, which seems pretty cumbersome. Perhaps you could use defaults in the handler, something like login_clickHandler(event:MouseEvent = null) Gabriel -- gabriel montagné láscaris comneno http://rojored.com +44 (0) 7500 709 209
Re: [flexcoders] Handler functions convention
Thanks Gabriel. Mike 2010/4/3 gabriel montagné gabr...@rojored.com On 03/04/2010, Mike Chang mik...@gmail.com mikecc%40gmail.com wrote: I noticed in many examples on the web handler functions mostly have a parameter event, even though the event isn't used (such as even.target). I'm wondering if there's a reason for this convention. I'd say it's up to you, but if you subscribe to the event using ActionScript, not the mxml handler sugar, then you'll always get the event. I have to pass a null in case it isn't triggered by the event, which seems pretty cumbersome. Perhaps you could use defaults in the handler, something like login_clickHandler(event:MouseEvent = null) Gabriel -- gabriel montagné láscaris comneno http://rojored.com +44 (0) 7500 709 209