MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 244

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Using a class file in Flash
To create an instance of an ActionScript class, use the
constructor function. The constructor function always has the same name as the class and
returns an instance of the class, which you typically assign to a variable. For example, if you
were using the User class from
following code to create a new User object:
var firstUser:User = new User();
In some cases, you don't need to create an instance of a class to use its properties and
methods. For more information on class (static) members, see
members" on page 298
Use the dot (
) operator to access the value of a property in an instance. Type the name of the
.
instance on the left side of the dot, and the name of the property on the right side. For
example, in the following statement,
firstUser.username
You can also use the top-level or built-in classes that make up the ActionScript language in a
Flash document. For example, the following code creates a new Array object and then shows
its
property:
length
var myArray:Array = new Array("apples", "oranges", "bananas");
trace(myArray.length); // 3
For more information on using custom classes in Flash, see
in Flash" on page
276. For information on the constructor function, see
constructor function" on page
244
Classes
"Writing custom class files" on page
and
"Static methods and properties" on page
is the instance and
firstUser
268.
operator to invoke the class's
new
235, you would write the
"About class (static)
username
"Example: Using custom class files
"Writing the
249.
is the property:

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

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?

This manual is also suitable for:

Flash 8

Table of Contents