Skip to main content
Participant
February 13, 2008
Question

typecasting in as3?

  • February 13, 2008
  • 3 replies
  • 686 views
I know how to do this in Java, but am new to AS3. How can I typecast a character to a number? Thanks for your help.

PS: this is what I'm doing:
This topic has been closed for replies.

3 replies

Participating Frequently
March 25, 2008
You can convert a string to an integer with parseInt(myChar); as long as the string containes a number. Also, you can use parseFloat(myChar); to convert to a floating-point (decimal) number. However, int(myChar); should also work, but only because Flash has to guess what you are trying to do so this is not recommended.
Inspiring
March 25, 2008
It think something like this

var myString:String = "12";
var myNumber:Number = Number(myString);

for the other way around you could use String(myNumber) to convert it to
a string.

tamagorci

cbthom wrote:
> I know how to do this in Java, but am new to AS3. How can I typecast a character to a number? Thanks for your help.
>
Damon Edwards
Inspiring
February 13, 2008
using the 'as' operator, however, I don't believe you can typecast a string as a number, could be wrong though.