[flexcoders] Re: curly braces and functions in mxml

2009-03-06 Thread oneworld95
Both in this case do the same thing. Curly braces tell Flex that it should 
treat the contents as ActionScript (thus you can Ctrl-click it). It's basically 
a function call. Take a look here for an explanation: 
http://www.onflex.org/ted/2005/06/property-binding-in-flex.php

In the case of your code, the click property of the Button component converts 
the string it receives to a function call automatically; it's redundant to use 
the curly braces but it shouldn't hurt anything. 

- Alex C

--- In flexcoders@yahoogroups.com, Rick Schmitty flexc...@... wrote:

 Is there a difference between
 
 mx:Button click=onClick()/
 
 and
 
 mx:Button click={onClick()}/
 
 The only thing I've notice is in the latter I can CTRL+Click on
 onClick and it takes me to the onClick function, while the first one
 does nothing





[flexcoders] Re: curly braces and functions in mxml

2009-03-06 Thread Tim Hoff

Hi Rick,

Both will work, but you don't need the binding (curly) braces for events
(click).  This is a common mistake; one that I've made myself.  In
essence, when you use the curly braces to bind, you are creating an
event listener; usually to a variable.  When the variable changes
(except for arrays), the binding mechanism will automatically update any
properties that are bound to the variable.  This works great for
properties and styles, but is un-necessary for events. Simply by using
an event in an mxml tag, you are already doing the same thing; creating
an event listener.  When the event is dispatched, do something; done. 
Sometimes binding is confused with just referencing properties and
methods.

-TH

--- In flexcoders@yahoogroups.com, Rick Schmitty flexc...@... wrote:

 Is there a difference between

 mx:Button click=onClick()/

 and

 mx:Button click={onClick()}/

 The only thing I've notice is in the latter I can CTRL+Click on
 onClick and it takes me to the onClick function, while the first one
 does nothing