Actionscript Convert String to Int

greg picture greg · May 27, 2011 · Viewed 47k times · Source

I am using Actionscript 2.0

In a Brand new Scene. My only bit of code is:

    trace(int('04755'));
    trace(int('04812'));

Results in:

  • 2541

  • 4812

Any idea what I am doing wrong/silly?

By the way, I am getting this source number from XML, where it already has the leading 0. Also, this works perfect in Actionscript 3.

Answer

Rahul Singhai picture Rahul Singhai · Mar 10, 2013

In AS3, you can try:

parseInt('04755', 10)

10 above is the radix.