HomeComputer programmingAS3: How to Convert Number to String

AS3: How to Convert Number to String

Frequently, it is nice to convert numbers to strings in actionscript 3. For example, this will correct the error — 1067: Implicit coercion of a value of type Number to an unrelated type String.


In my neverending journey to teach myself actionscript, I have once again started pounding through some code.

In short to convert a number to a string, use the following construct:

text = String(number);

If you try to avoid this step, it’ll throw the following error…

1067: Implicit coercion of a value of type Number to an unrelated type String.

Here is some example code that will throw the error:


var time:Date= new Date();
var txt:String;
txt = time.milliseconds;

This code works correctly:


var time:Date= new Date();
var txt:String;
txt = String(time.milliseconds);

David Kirk
David Kirk
David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
RELATED ARTICLES

17 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android