to possibly help in the "vague understanding," the ()?: stuff is an
inline if statement.  (mynum > maxval) ?  is like saying If mynum is
greater than maxval.  ":" is the else.

re your errors: from eyeballing everything, numberformatter.format
returns a string (control click into ".format" in flexbuilder to see
the framework code).  I could be making this up, but NaN might be a
class too, so it is probably the cause of your coercion error.  I
would break out everything into a function that returns a string (for
the text property of your label), so the last part would be "return
PrepForDisplay.format(mynum).toString()" (or "as String").

Good Luck
Jeremy



--- In flexcoders@yahoogroups.com, Blair Cox <[EMAIL PROTECTED]> wrote:
>
> 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:
> 
> <mx:NumberFormatter id="PrepForDisplay"        precision="2"
> rounding="up"        decimalSeparatorTo="."       
thousandsSeparatorTo=","
> useThousandsSeparator="true"        useNegativeSign="true"/>
> 
> -- 
> Blair Cox
> 
> http://www.luminultra.com
>  
> 
> From: Sid Maskit <[EMAIL PROTECTED]>
> Reply-To: <flexcoders@yahoogroups.com>
> Date: Thu, 31 Jul 2008 07:51:38 -0700 (PDT)
> To: <flexcoders@yahoogroups.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:
> 
> <mx:Label text="{(myNumber is NaN) ? 0 : PrepForDispl ay.format(
myNumber)
> }"/>
> 
> 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:
> 
> <mx:Label text="{(myNumber > maxValue) ? 0 : PrepForDispl ay.format(
> myNumber) }"/>
> 
> If you put the two together, it would look something like this:
> 
> <mx:Label text="{(myNumber is NaN) ? 0 : (myNumber > maxValue) ? 0 :
> PrepForDispl ay.format( myNumber) }"/>
> 
>  
> Sid Maskit
> Partner 
> CraftySpace
> Better Websites for a Better World
> http://www.CraftySpace.com
> blog: http://smaskit.blogspot.com/
>


Reply via email to