EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 112

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
112 Data and Data Types
This example defines two string variables (firstNum and secondNum), which are added
together. The initial result is that the numbers are concatenated instead of added because they
are a String data type. The second trace statement converts both numbers to a Number data
type before performing the addition that yields the proper result. Data conversion is
important when working with data loaded using XML or FlashVars, as shown in the following
example:
var firstNum:String = "17";
var secondNum:String = "29";
trace(firstNum + secondNum); // 1729
trace(Number(firstNum) + Number(secondNum)); // 46
For more information on data conversion functions, see the entry for each conversion
function in ActionScript 2.0 Language Reference:
Array function, Boolean function,
Number function
, Object function, and String function.

Table of Contents

Related product manuals