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(fi 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
.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...