About ActionScript 1.0
Many Flash users can greatly benefit from using ActionScript 2.0, especially with
complex applications. For information on using ActionScript 2.0, see
"Classes," on page
ActionScript is an object-oriented programming language. Object-oriented programming
uses objects, or data structures, to group together properties and methods that control the
object's behavior or appearance. Objects let you organize and reuse code. After you define an
object, you can refer to it by name without having to redefine it each time you use it.
A class is a generic category of objects. A class defines a series of objects that have common
properties and can be controlled in the same ways. Properties are attributes that define an
object, such as its size, position, color, transparency, and so on. Properties are defined for a
class, and values for the properties are set for individual objects in the class. Methods are
functions that can set or retrieve properties of an object. For example, you can define a
method to calculate the size of an object. As with properties, methods are defined for an
object class and then invoked for individual objects in the class.
ActionScript includes several built-in classes, including the MovieClip class, Sound class, and
others. You can also create custom classes to define categories of objects for your applications.
Objects in ActionScript can be pure containers for data, or they can be graphically represented
on the Stage as movie clips, buttons, or text fields. All movie clips are instances of the built-in
MovieClip class, and all buttons are instances of the built-in Button class. Each movie clip
instance contains all the properties (for example,
all the methods (for example,
MovieClip class.
To define a class, you create a special function called a constructor function. (Built-in classes
have built-in constructor functions.) For example, if you want information about a bicycle
rider in your application, you could create a constructor function,
properties
and
time
distance
biker is traveling:
function Biker(t, d) {
this.time = t;
this.distance = d;
this.getSpeed = function() {return this.time / this.distance;};
}
792
Object-Oriented Programming with ActionScript 1.0
225.
gotoAndPlay()
and the method
,
_height
_rotation
,
,
loadMovie()
startDrag()
Biker()
, which tells you how fast the
getSpeed()
Chapter 7,
,
) and
_totalframes
) of the
, with the
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?