Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Number > toString (Number.toString method) | |||
public toString(radix:Number) : String
Returns the string representation of the specified Number object (myNumber). If the value of the Number object is a decimal number without a leading zero (such as .4), Number.toString() adds a leading zero (0.4).
Availability: ActionScript 1.0; Flash Player 5
radix:Number - Specifies the numeric base (from 2 to 36) to use for the number-to-string conversion. If you do not specify the radix parameter, the default value is 10.
String - A string.
The following example uses 2 and 8 for the radix parameter and returns a string that contains the corresponding representation of the number 9:
var myNumber:Number = new Number(9); trace(myNumber.toString(2)); // output: 1001 trace(myNumber.toString(8)); // output: 11
The following example results in a hexadecimal value.
var r:Number = new Number(250); var g:Number = new Number(128); var b:Number = new Number(114); var rgb:String = "0x"+ r.toString(16)+g.toString(16)+b.toString(16); trace(rgb); // output: rgb:0xFA8072 (Hexadecimal equivalent of the color 'salmon')
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002033.html