Re: [flexcoders] Re: NaN and Infinity showing in output - How to modify?
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: flexcoders@yahoogroups.com 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' amp;amp; 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
Re: [flexcoders] Re: NaN and Infinity showing in output - How to modify?
True. Good point. Event handler attributes are assumed to contain code. Most attributes are of a type like string or number, and will need braces to get a value treated as code. I'm not sure if there are other attributes beside event handlers which are also assumed to contain code, but it wouldn't surprise me if there are some others. 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: flexcoders@yahoogroups.com Sent: Thursday, July 31, 2008 1:01:13 PM Subject: [flexcoders] Re: NaN and Infinity showing in output - How to modify? --- In [EMAIL PROTECTED] ups.com, Sid Maskit [EMAIL PROTECTED] wrote: 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. In at least some instances, MXML will run code that is not within braces, for instance mx:LinkBar id=chartSwitcher borderStyle= solid itemClick=invalida teDisplayList( ) / It's not treating the text within the itemClick property as a string, but as code to be run. I'm not certain exactly where the line is, but you don't ALWAYS have to enclose your as expressions in brackets to get them to run. -Amy
RE: [flexcoders] Re: NaN
Actually you need to use isNaN(myField) J From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Andrew Spaulding Sent: Monday, August 01, 2005 9:24 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: NaN NaN stands for Not a Number, and it is a String. So to correct you if statement you would have to check (myField == NaN). ** at least i think its a string haha, can't remember :p Hope that helps, Andrew www.flexdaddy.info --- In flexcoders@yahoogroups.com, Ghislain Simard [EMAIL PROTECTED] wrote: I have in the NetConnectionDebugger a field with a value of NaN. The following condition doesn't see the NaN...why ? and how to make the condition working? if (myField == NaN){ dosomething; } -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Computer software testing Macromedia flex Development Software developer YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.