Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

typecasting in as3?

New Here ,
Feb 12, 2008 Feb 12, 2008
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:
TOPICS
ActionScript
702
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Feb 12, 2008 Feb 12, 2008
using the 'as' operator, however, I don't believe you can typecast a string as a number, could be wrong though.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2008 Mar 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.
>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 25, 2008 Mar 25, 2008
LATEST
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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines