EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 793

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 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...
About ActionScript 1.0 793
In this example, you create a function that needs two pieces of information, or parameters, to
do its job:
t and d. When you call the function to create new instances of the object, you pass
it the parameters. The following code creates instances of the object Biker called
emma and
hamish, and it traces the speed of the emma instance, using the getSpeed() method from the
previous ActionScript:
emma = new Biker(30, 5);
hamish = new Biker(40, 5);
trace(emma.getSpeed()); // traces 6
In object-oriented scripting, classes can receive properties and methods from each other
according to a specific order, which is called inheritance. You can use inheritance to extend or
redefine the properties and methods of a class. A class that inherits from another class is called
a subclass. A class that passes properties and methods to another class is called a superclass. A
class can be both a subclass and a superclass.
An object is a complex data type containing zero or more properties and methods. Each
property, like a variable, has a name and a value. Properties are attached to the object and
contain values that can be changed and retrieved. These values can be of any data type: String,
Number, Boolean, Object, MovieClip, or undefined. The following properties are of various
data types:
customer.name = "Jane Doe";
customer.age = 30;
customer.member = true;
customer.account.currentRecord = 609;
customer.mcInstanceName._visible = true;
The property of an object can also be an object. In line 4 of the previous example, account is
a property of the object
customer, and currentRecord is a property of the object account.
The data type of the
currentRecord property is Number.

Table of Contents

Related product manuals