
MovieClip.beginFill() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
632
|
ActionScript Language Reference
However, properties inherited through initObject’s prototype chain are not copied to
the clip. Only direct properties are transferred. To determine whether a property is inher-
ited or direct, use Object.hasOwnProperty(). Built-in movie clip properties, such as
_x
and _rotation, and event handlers, such as onEnterFrame(), can be set (i.e., copied to
the newly created movie clip instance) via
initObject. For example:
var tempObj = new Object();
// Set _rotation
tempObj._rotation = 200;
// Assign an onEnterFrame() callback
tempObj.onEnterFrame = function () {
this._x++
};
// Once attached, tennisBall_mc will be rotated by 200 degrees and will
// start moving one pixel right per frame due to the onEnterFrame() handler
court_mc.attachMovie("ball_symbol", "tennisBall_mc", 1, tempObj);
In Flash 6, the initObject parameter is used to set properties in newName that will be used by
its class constructor (effectively the same as passing arguments to the constructor). A movie
clip symbol’s class constructor is defined by the Object.registerClass() method. For conve-
nience,
initObject can be specified as an anonymous object. For example:
court_mc.attachMovie("ball_symbol", "tennisBall_mc", 1, {speed: 200, _x: 165} );
The initObject parameter ...