Re: [flexcoders] Handler functions convention
On 5 April 2010 19:25, Gordon Smith 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
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é mailto:gabr...@rojored.com>> On 03/04/2010, Mike Chang mailto: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
Thanks Gabriel. Mike 2010/4/3 gabriel montagné > > > On 03/04/2010, Mike Chang > 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 03/04/2010, Mike Chang 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