Tostring (Number.tostring Method) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

Example
This example compares the result of dividing the following values.
var posResult:Number = 1/0;
if (posResult == Number.POSITIVE_INFINITY) {
trace("posResult = "+posResult); // output: posResult = Infinity
}
var negResult:Number = -1/0;
if (negResult == Number.NEGATIVE_INFINITY) {
trace("negResult = "+negResult); // output: negResult = -Infinity

toString (Number.toString method)

public toString(radix:Number) : String
Returns the string representation of the specified Number object (
Availability: ActionScript 1.0; Flash Player 5
Parameters
- Specifies the numeric base (from 2 to 36) to use for the number-to-string
radix:Number
conversion. If you do not specify the
Returns
- A string.
String
Example
The following example uses 2 and 8 for the
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')
parameter, the default value is 10.
radix
parameter and returns a string that
radix
).
myNumber
Number
989

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash 8

Table of Contents