Creating A Custom Object In Actionscript 1.0 - MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Creating a custom object in
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
To create a custom object, you define a constructor function. A constructor function is always
given the same name as the type of object it creates. You can use the keyword
body of the constructor function to refer to the object that the constructor creates; when you
call a constructor function, Flash passes
example, the following code is a constructor function that creates a circle with the property
:
radius
function Circle(radius) {
this.radius = radius;
}
After you define the constructor function, you must create an instance of the object. Use the
operator before the name of the constructor function, and assign a variable name to the
new
new instance. For example, the following code uses the
with a radius of 5 and assigns it to the variable
myCircle = new Circle(5);
An object has the same scope as the variable to which it is assigned.
794
Object-Oriented Programming with ActionScript 1.0
225.
this
to the function as a hidden parameter. For
operator to create a Circle object
new
:
myCircle
Chapter 7,
inside the
this

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents