
36
Chapter 2: ActionScript Basics
Object
An object is a collection of properties. Each property has a name and a value. The value of a
property can be any Flash data type, even the object data type. This allows you to arrange objects
inside each other, or
nest
them. To specify objects and their properties, you use the dot (
.
)
operator. For example, in the following code,
hoursWorked
is a property of
weeklyStats
, which
is a property of
employee
:
employee.weeklyStats.hoursWorked
You can use the built-in ActionScript objects to access and manipulate specific kinds of
information. For example, the Math object has methods that perform mathematical operations
on numbers you pass to them. This example uses the
sqrt()
method:
squareRoot = Math.sqrt(100);
The ActionScript MovieClip object has methods that let you control movie clip symbol instances
on the Stage. This example uses the
play()
and
nextFrame()
methods:
mcInstanceName.play();
mc2InstanceName.nextFrame();
You can also create custom objects to organize information in your Flash application. To add
interactivity to an application with ActionScript, you’ll need many different pieces of
information: for example, you might need a user’s name, the speed of a ball, the names of items in
a shopping cart, the number of frames loaded, the user’s ZIP Code, or the key that was pressed
last. Creating custom objects lets you organize this information into groups, simplify your
scripting, and reuse your scripts.
MovieClip
Movie clips are symbols that can play animation in a Flash application. They are the only data
type that refers to a graphic element. The MovieClip data type allows you to control movie clip
symbols using the methods of the MovieClip class. You call the methods using the dot (
.
)
operator, as shown here:
my_mc.startDrag(true);
parent_mc.getURL("http://www.macromedia.com/support/" + product);
Null
The null data type has only one value,
null
. This value means “no value”—that is, a lack of data.
The
null
value can be used in a variety of situations. Here are some examples:
•
To indicate that a variable has not yet received a value
•
To indicate that a variable no longer contains a value
•
As the return value of a function, to indicate that no value was available to be returned by
the function
•
As a parameter to a function, to indicate that a parameter is being omitted
Undefined
The undefined data type has one value,
undefined
, and is used for a variable that hasn’t been
assigned a value.
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...