When the first digit in a number (or a String being converted to a number) is 0 the Flash Player treats the numberas Octal.  We ended up putting special code in the MXML interpreter to leave “numbers” starting with 0 as strings to avoid the issue since most people are indicating ids or skus etc with something like this.

 

Matt

 


From: Rich Tretola [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 08, 2005 1:33 AM
To: [EMAIL PROTECTED]
Subject: Re: [flexcoders] Hex Issue on a string to number cast?

 

Thanks,

I know that I can use a loop, I was just wondering why the default
behavior in actionscript is to automatically assume that testString is
hex and that testNumber evaluates to 64 in the sample below:

var testString 0100:String;
var testNumber = Number(testString);

Rich



On Tue, 8 Mar 2005 11:49:38 +0530, Manish Jethani
<[EMAIL PROTECTED]> wrote:
>
> On Mon, 7 Mar 2005 15:16:02 -0500, Rich Tretola <[EMAIL PROTECTED]> wrote:
>
> > I have a text input that I am using as a free input field for a
> > number.  I have it restrictedto 0-9 characters and am casting it to a
> > number when setting the value to my object.  The problem is that if
> > someone enters a value with a leading 0 such as 0100 it casts to 64.
>
>       var s:String = "000100";
>       if (s.charAt(0) == "0") {
>         for (var i:Number = 0; i < s.length; i++)
>           if (s.charAt(i) != "0")
>             break;
>         s = s.substr(i);
>       }
>       trace(s);
>
> Manish
>
>
> Yahoo! Groups Links
>
>
>
>
>


Reply via email to