The following example shows how you can use the
object that you trace:
// Create a new instance of LoadVars class.
var my_lv:LoadVars = new LoadVars();
/* typeof operator doesn't specify class, only specifies that my_lv is an
object */
var typeResult:String = typeof(my_lv);
trace(typeResult); // object
In this example, you create a new String variable named
Number data type:
var myName:String = new String("17");
trace(myName instanceof String); // true
var myNumber:Number = new Number(myName);
trace(myNumber instanceof Number); // true
For more information about these operators, see
in the ActionScript 2.0 Language Reference. For more information on testing and
operator
debugging, see
Chapter 18, "Debugging Applications," on page 711
inheritance and interfaces, see
on classes, see
Chapter 7, "Classes," on page
About variables
A variable is a container that holds information. The following ActionScript shows what a
variable looks like in ActionScript:
var myVariable:Number = 10;
This variable holds a numerical value. The use of
type of value that variable holds, called data typing. For more information on data typing, see
"About assigning data types and strict data typing" on page 81
on page
82.
The container (represented by the variable name) is always the same throughout your
ActionScript, but the contents (the value) can change. You can change the value of a variable
in a script as many times as you want. When you change the value of a variable while the SWF
file plays, you can record and save information about what the user has done, record values
that change as the SWF file plays, or evaluate whether a condition is
might need the variable to continually update while the SWF file plays, such as when a
player's score changes in a Flash game. Variables are essential when you create and handle user
interaction in a SWF file.
86
Data and Data Types
typeof operator
Chapter 8, "Inheritance," on page
225.
:Number
operator to return the kind of
typeof
, and then convert it into a
myName
and
For more information on
301. For more information
in the previous code assigns the
and
"Assigning a data type"
true
instanceof
or
. You
false
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?