EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 36

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 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...
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 users name, the speed of a ball, the names of items in
a shopping cart, the number of frames loaded, the users 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 hasnt been
assigned a value.

Table of Contents

Related product manuals