RE: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-08-01 Thread Gordon Smith
I don't recommend writing complicated binding expressions, because you
have to use < in place of <, > in place of >, and & in place
of &.

 

Gordon Smith

Adobe Flex SDK Team

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sid Maskit
Sent: Friday, August 01, 2008 2:54 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 

"Eww," eh? Well, gee, Tom, I hope I didn't spoil your breakfast or
anything ;)

I think both your refactorings are good ones. I was definitely in "how
do we get this working" mode, not "how do we get this as elegantly
written as possible" mode: i.e. I was in code-writing not refactoring
mode. So I suppose I shouldn't complain about you pointing out a bad
smell coming from the code writing.

Having said that, I have to admit that I am not at all clear as to
protocol for how much ActionScript is acceptable within braces while
assigning to an MXML attribute, or whether there are accepted standards
for this. I have the fear that this might be a religious question, but
maybe not. If there are accepted protocols, I'd love to hear what they
are.

Just to help clarify things, I'm wondering whether you have any
objection to ternary statements, or if you do just feel that this is too
much code to have within an attribute assignment. For example, would
this satisfy your objection:







 

Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/





 

- Original Message 
From: Tom Chiverton <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Friday, August 1, 2008 5:04:56 AM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

On Thursday 31 Jul 2008, Sid Maskit wrote:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
<http://gr!%0d%0a%20oups.yahoo.com/group/flexcoders/files/flexcodersFAQ.
txt> 
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo
<http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo> ! Groups
Links


(Yahoo! ID required)

mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> 



 

 



Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-08-01 Thread Sid Maskit
"Eww," eh? Well, gee, Tom, I hope I didn't spoil your breakfast or anything ;)

I think both your refactorings are good ones. I was definitely in "how do we 
get this working" mode, not "how do we get this as elegantly written as 
possible" mode: i.e. I was in code-writing not refactoring mode. So I suppose I 
shouldn't complain about you pointing out a bad smell coming from the code 
writing.

Having said that, I have to admit that I am not at all clear as to protocol for 
how much ActionScript is acceptable within braces while assigning to an MXML 
attribute, or whether there are accepted standards for this. I have the fear 
that this might be a religious question, but maybe not. If there are accepted 
protocols, I'd love to hear what they are.

Just to help clarify things, I'm wondering whether you have any objection to 
ternary statements, or if you do just feel that this is too much code to have 
within an attribute assignment. For example, would this satisfy your objection:







 Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/



- Original Message 
From: Tom Chiverton <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Friday, August 1, 2008 5:04:56 AM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?

On Thursday 31 Jul 2008, Sid Maskit wrote:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links




  

Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-08-01 Thread Tom Chiverton
On Thursday 31 Jul 2008, Sid Maskit wrote:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Blair Cox
Hmm, sorry the last post left a part out, it was shown lower down:



Adding the ³² as you stated, returns an error for mx:Label, ³>² or ³/>².
The zero is what is display in the application, if I could provide a short
string instead, it would be ideal. Even if the initial default text of the
label was ³whatever² until a calculated value was entered. But there are
many, many of these calculations to perform and I would like to find the
simplest answer. Close though, thanks for the help.

-- 
Blair 




From: Laurent Cozic <[EMAIL PROTECTED]>
Reply-To: 
Date: Thu, 31 Jul 2008 09:28:51 -0700 (PDT)
To: 
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

How about:

sNaN(mynumber) ? 0 : ""
 
--
Laurent Cozic

Flash, Flex and Web Application development
http://pogopixels.com


- Original Message 
From: Blair Cox <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 5:19:46 PM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

Just one more question. The zero works for me, but I¹m sure I¹ll be asked to
make it blank. Any hints as to how this could be accomplished? Coming from
the Flash side of things, all I would be looking to do is change the alpha
value of the label to zero if the value was 0.


isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminult ra.com <http://www.luminultra.com>
 





From: Sid Maskit <[EMAIL PROTECTED] com>
Reply-To: <[EMAIL PROTECTED] ups.com <http://ups.com> >
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: <[EMAIL PROTECTED] ups.com>
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

If the format function is a custom function you have written, you could just
have it check whether you like the result it is about to return, and if not,
return something else. If that is not the case, I believe that you should be
able to put tests into your binding statement.

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by
looking for the greatest possible value of the number. Assuming that you
have set up the variable maxValue to contain that value, you should be able
to do something like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySp ace.com <http://www.CraftySpace.com>
blog: http://smaskit. blogspot. com/ <http://smaskit.blogspot.com/>
 
 


Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Sid Maskit
Actually, if you are just going to hide the label field, you can just have it 
display the result of the formatting, and put the checking for NaN and infinity 
into the setting for visibility. Since you are going to hide the label and it 
has a value you don't like, you don't really care what it is displaying when it 
is invisible.

 Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/



- Original Message 
From: Sid Maskit <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 9:37:19 AM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?


Try something like this:



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.

Finally, the reason that there is && instead of  && is that we are 
inside of MXML, which is to say inside of XML, and we cannot use the & 
character there, but must escape it.

 Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySp ace.com
blog: http://smaskit. blogspot. com/



- Original Message 
From: Blair Cox <[EMAIL PROTECTED] a.com>
To: [EMAIL PROTECTED] ups.com
Sent: Thursday, July 31, 2008 9:19:46 AM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?


Just one more question. The zero works for me, but I’m sure I’ll be asked to 
make it blank. Any hints as to how this could be accomplished? Coming from the 
Flash side of things, all I would be looking to do is change the alpha value of 
the label to zero if the value was 0.


isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminult ra.com






From: Sid Maskit <[EMAIL PROTECTED] com>
Reply-To: <[EMAIL PROTECTED] ups.com>
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: <[EMAIL PROTECTED] ups.com>
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?

 
 

If the format function is a custom function you have written, you could just 
have it check whether you like the result it is about to return, and if not, 
return something else. If that is not the case, I believe that you should be 
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by looking 
for the greatest possible value of the number. Assuming that you have set up 
the variable maxValue to contain that value, you should be able to do something 
like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySp ace.com
blog: http://smaskit. blogspot. com/
 
 


  

Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Sid Maskit
Try something like this:



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.

Finally, the reason that there is && instead of  && is that we are 
inside of MXML, which is to say inside of XML, and we cannot use the & 
character there, but must escape it.

 Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/



- Original Message 
From: Blair Cox <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 9:19:46 AM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?


Just one more question. The zero works for me, but I’m sure I’ll be asked to 
make it blank. Any hints as to how this could be accomplished? Coming from the 
Flash side of things, all I would be looking to do is change the alpha value of 
the label to zero if the value was 0.


isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminult ra.com






From: Sid Maskit <[EMAIL PROTECTED] com>
Reply-To: <[EMAIL PROTECTED] ups.com>
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: <[EMAIL PROTECTED] ups.com>
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?

 
 

If the format function is a custom function you have written, you could just 
have it check whether you like the result it is about to return, and if not, 
return something else. If that is not the case, I believe that you should be 
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by looking 
for the greatest possible value of the number. Assuming that you have set up 
the variable maxValue to contain that value, you should be able to do something 
like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySp ace.com
blog: http://smaskit. blogspot. com/
  


  

Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Laurent Cozic
How about:

sNaN(mynumber) ? 0 : ""

 --
Laurent Cozic

Flash, Flex and Web Application development
http://pogopixels.com



- Original Message 
From: Blair Cox <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 5:19:46 PM
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?


Just one more question. The zero works for me, but I’m sure I’ll be asked to 
make it blank. Any hints as to how this could be accomplished? Coming from the 
Flash side of things, all I would be looking to do is change the alpha value of 
the label to zero if the value was 0.


isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminult ra.com






From: Sid Maskit <[EMAIL PROTECTED] com>
Reply-To: <[EMAIL PROTECTED] ups.com>
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: <[EMAIL PROTECTED] ups.com>
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to modify?

 
 

If the format function is a custom function you have written, you could just 
have it check whether you like the result it is about to return, and if not, 
return something else. If that is not the case, I believe that you should be 
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by looking 
for the greatest possible value of the number. Assuming that you have set up 
the variable maxValue to contain that value, you should be able to do something 
like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySp ace.com
blog: http://smaskit. blogspot. com/
 


  

Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Blair Cox
Just one more question. The zero works for me, but I¹m sure I¹ll be asked to
make it blank. Any hints as to how this could be accomplished? Coming from
the Flash side of things, all I would be looking to do is change the alpha
value of the label to zero if the value was 0.


isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminultra.com
 





From: Sid Maskit <[EMAIL PROTECTED]>
Reply-To: 
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: 
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

If the format function is a custom function you have written, you could just
have it check whether you like the result it is about to return, and if not,
return something else. If that is not the case, I believe that you should be
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by
looking for the greatest possible value of the number. Assuming that you
have set up the variable maxValue to contain that value, you should be able
to do something like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/



Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Blair Cox
Hi Sid, thanks a lot for your help. I figured it out! Really just need a
starting point for where to look. Cheers!

isNaN(mynumber) ? 0 :


-- 
Blair Cox

http://www.luminultra.com
 





From: Sid Maskit <[EMAIL PROTECTED]>
Reply-To: 
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: 
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

If the format function is a custom function you have written, you could just
have it check whether you like the result it is about to return, and if not,
return something else. If that is not the case, I believe that you should be
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by
looking for the greatest possible value of the number. Assuming that you
have set up the variable maxValue to contain that value, you should be able
to do something like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/


- Original Message 
From: cox.blair <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 6:41:18 AM
Subject: [flexcoders] NaN and Infinity showing in output - How to modify?

 
 

I seem to have trouble explaining myself here, hard when you are just
learning. Perhaps this will be better.

Is it possible to remove, change or hide any label or text output that
displays NaN or Infinity?

I'm performing a very simply calculation where the user enters a
number in a form and it is calculated and displayed. Simple and does
what I need. In some instances, there are more variables required and
until they are provided, the output display NaN or Infinity.

How could I easily adjust these? It could be a default display of
zero, it could be to display nothing, whatever is the easiest and most
straight forward method.

Below is only an example of how I'm taking the user input from the
form and passing the variable on to the Label text output.

{Number( userInput. text) * (1 +
Number(otherUserInp ut.text)) * 1 /
Number(otherOtherUs erInput.text) }

The answer is output to:



Thank you, any assistance you can provide would be welcomed.

 
  

 
 




Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Blair Cox
Hi Sid, thanks for the reply. I tried your first solution since I did not
create a custom function and it returns;

1067: Implicit coercion of value of type Number to an unrelated type Class

I have a vague understanding of what is occurring here. Any way around it?
How difficult would it be to modify or create a custom function?

What I have now is simply:



-- 
Blair Cox

http://www.luminultra.com
 

From: Sid Maskit <[EMAIL PROTECTED]>
Reply-To: 
Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
To: 
Subject: Re: [flexcoders] NaN and Infinity showing in output - How to
modify?

 
 

If the format function is a custom function you have written, you could just
have it check whether you like the result it is about to return, and if not,
return something else. If that is not the case, I believe that you should be
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by
looking for the greatest possible value of the number. Assuming that you
have set up the variable maxValue to contain that value, you should be able
to do something like this:



If you put the two together, it would look something like this:



 
Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/




Re: [flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread Sid Maskit
If the format function is a custom function you have written, you could just 
have it check whether you like the result it is about to return, and if not, 
return something else. If that is not the case, I believe that you should be 
able to put tests into your binding statement. 

You could test for NaN with something like this:



I'm not sure about infinity, but I assume that you can test for this by looking 
for the greatest possible value of the number. Assuming that you have set up 
the variable maxValue to contain that value, you should be able to do something 
like this:



If you put the two together, it would look something like this:



 Sid Maskit
Partner 
CraftySpace
Better Websites for a Better World
http://www.CraftySpace.com
blog: http://smaskit.blogspot.com/



- Original Message 
From: cox.blair <[EMAIL PROTECTED]>
To: flexcoders@yahoogroups.com
Sent: Thursday, July 31, 2008 6:41:18 AM
Subject: [flexcoders] NaN and Infinity showing in output - How to modify?


I seem to have trouble explaining myself here, hard when you are just
learning. Perhaps this will be better.

Is it possible to remove, change or hide any label or text output that
displays NaN or Infinity?

I'm performing a very simply calculation where the user enters a
number in a form and it is calculated and displayed. Simple and does
what I need. In some instances, there are more variables required and
until they are provided, the output display NaN or Infinity. 

How could I easily adjust these? It could be a default display of
zero, it could be to display nothing, whatever is the easiest and most
straight forward method.

Below is only an example of how I'm taking the user input from the
form and passing the variable on to the Label text output.

{Number( userInput. text) * (1 +
Number(otherUserInp ut.text)) * 1 /
Number(otherOtherUs erInput.text) }

The answer is output to:



Thank you, any assistance you can provide would be welcomed.

 


  

[flexcoders] NaN and Infinity showing in output - How to modify?

2008-07-31 Thread cox.blair
I seem to have trouble explaining myself here, hard when you are just
learning. Perhaps this will be better.

Is it possible to remove, change or hide any label or text output that
displays NaN or Infinity?

I'm performing a very simply calculation where the user enters a
number in a form and it is calculated and displayed. Simple and does
what I need. In some instances, there are more variables required and
until they are provided, the output display NaN or Infinity. 

How could I easily adjust these? It could be a default display of
zero, it could be to display nothing, whatever is the easiest and most
straight forward method.

Below is only an example of how I'm taking the user input from the
form and passing the variable on to the Label text output.

{Number(userInput.text) * (1 +
Number(otherUserInput.text)) * 1 /
Number(otherOtherUserInput.text)}

The answer is output to:



Thank you, any assistance you can provide would be welcomed.