I think I see your point here, and I guess that I have not made mine clearly
enough, so here is a little more on this.
When we say text="{myNumber}", we are really setting up whatever is within the
braces as an event handler for the event dispatched whenever myNumber changes.
If we think of binding as setting up that relationship, then yes, everything in
this thread is using binding. However, I think it is common for beginners to
think of that statement as binding the text attribute to the latest value of
myNumber, and to think of binding as doing no more than such assignments.
I think it is important part of learning flex to realize that one can do much
more than that. In the largest sense, one can do almost anything that is
possible with a single ActionScript statement, so long as it returns a valid
value for the attribute to which it is assigned, in this case the text
attribute. For example, one could do something rather complicated, like this:
text="{(myNumber != 0) ? myFunction() : myOtherFunction()}"
So long as both functions returned a value that could be validly assigned to
the text attribute, this approach is valid, and we can obviously do any valid
ActionScript within either function. I'm not sure that this approach would be a
best practice, but the point is that we are doing a lot more than simply taking
the value of myNumber and assigning it to text.
Finally, although I do not think you meant to imply this, I think it is worth
saying that one cannot use ActionScript within an assignment to an MXML
attribute without using braces. Well, one can, but it will be treated as a
string, not as code to be run.
Sid Maskit
Partner
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/
----- Original Message ----
From: Amy <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, July 31, 2008 10:47:30 AM
Subject: [flexcoders] Re: NaN and Infinity showing in output - How to modify?
--- In [EMAIL PROTECTED] ups.com, Sid Maskit <[EMAIL PROTECTED] > wrote:
>
> Try something like this:
>
> <mx:Label id="display" text="{(isNaN( myNumber as Number)) ? 0 :
PrepForDisplay. format(myNumber) }" visible="{display. text != '0'
&& display.text != 'In,fin,ity. 00'}"/>
>
> Note that you need to give the Label component and id, and use that
id to refer to it in your statements within braces.
>
> By the way, as you are no doubt noticing, the larger point here is
that braces are not just for binding, but can contain all sorts of
ActionScript.
The braces actually _are_ executing a binding here, as they will do
something different when the value of the variable changes. If the
value was not expected to change, you could do the same without the
braces.
HTH;
Amy