MACROMEDIA FLASH MX 2004-USING ACTIONSCRIPT IN FLASH Use Manual page 329

Using actionscript in flash
Hide thumbs Also See for FLASH MX 2004-USING ACTIONSCRIPT IN FLASH:
Table of Contents

Advertisement

Instead of adding
MountainBike class with Bike as its superclass, as shown in the following example:
MountainBike.prototype = new Bike();
Now you can call the
var myKona = new MountainBike(20, "teal");
trace(myKona.roll());
Movie clips do not inherit from each other. To create inheritance with movie clips, you can use
Object.registerClass()
Object.registerClass()
For more information on inheritance, see
Language Reference. For information on
to a subcomponent" in Using Components.
Adding getter/setter properties to objects in ActionScript 1
You can create getter/setter properties for an object using the
A getter function is a function with no parameters. Its return value can be of any type. Its type can
change between invocations. The return value is treated as the current value of the property.
A setter function is a function that takes one parameter, which is the new value of the property.
For instance, if property x is assigned by the statement x = 1, the setter function is passed the
parameter 1 of type Number. The return value of the setter function is ignored.
When Flash reads a getter/setter property, it invokes the getter function, and the function's return
value becomes a value of
function and passes it the new value as a parameter. If a property with the given name already
exists, the new property overwrites it.
You can add getter/setter properties to prototype objects. If you add a getter/setter property to a
prototype object, all object instances that inherit the prototype object inherit the getter/setter
property. You can add a getter/setter property in one location, the prototype object, and have it
propagate to all instances of a class (similar to adding methods to prototype objects). If a getter/
setter function is invoked for a getter/setter property in an inherited prototype object, the
reference passed to the getter/setter function is the originally referenced object, not the prototype
object.
For more information, see
The Debug > List Variables command in test mode supports getter/setter properties that you add
to objects using
with other properties of the object in the Output panel. Getter/setter properties are identified in
the Output panel with the prefix
command, see
"Using the Output panel" on page
to the MountainBike class and the Tricycle class, you can create the
roll()
method of MountainBike, as shown in the following example:
roll()
//traces 20
to assign a class other than the MovieClip class to movie clips. See
in Flash ActionScript Language Reference.
. When Flash writes a getter/setter property, it invokes the setter
prop
"Object.addProperty()"
Object.addProperty()
[getter/setter]
Object.__proto__
and
#initclip
#endinitclip
Object.addProperty()
in Flash ActionScript Language Reference.
. Properties that you add to an object in this way appear
. For more information on the List Variables
162.
and
in Flash ActionScript
super
see "Applying new skins
About ActionScript 1
method.
329

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING ACTIONSCRIPT IN FLASH and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx 2004 - actionscript

Table of Contents