awayjs-display
Version:
AwayJS displaylist classes
1,103 lines • 85.1 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Box_1 = require("awayjs-core/lib/geom/Box");
var ColorTransform_1 = require("awayjs-core/lib/geom/ColorTransform");
var Sphere_1 = require("awayjs-core/lib/geom/Sphere");
var MathConsts_1 = require("awayjs-core/lib/geom/MathConsts");
var Matrix3D_1 = require("awayjs-core/lib/geom/Matrix3D");
var Matrix3DUtils_1 = require("awayjs-core/lib/geom/Matrix3DUtils");
var Point_1 = require("awayjs-core/lib/geom/Point");
var Vector3D_1 = require("awayjs-core/lib/geom/Vector3D");
var AssetBase_1 = require("awayjs-core/lib/library/AssetBase");
var HierarchicalProperties_1 = require("../base/HierarchicalProperties");
var BoundsType_1 = require("../bounds/BoundsType");
var AlignmentMode_1 = require("../base/AlignmentMode");
var OrientationMode_1 = require("../base/OrientationMode");
var Transform_1 = require("../base/Transform");
var PickingCollision_1 = require("../pick/PickingCollision");
var DisplayObjectEvent_1 = require("../events/DisplayObjectEvent");
var TransformEvent_1 = require("../events/TransformEvent");
/**
* The DisplayObject class is the base class for all objects that can be
* placed on the display list. The display list manages all objects displayed
* in flash. Use the DisplayObjectContainer class to arrange the
* display objects in the display list. DisplayObjectContainer objects can
* have child display objects, while other display objects, such as Shape and
* TextField objects, are "leaf" nodes that have only parents and siblings, no
* children.
*
* <p>The DisplayObject class supports basic functionality like the <i>x</i>
* and <i>y</i> position of an object, as well as more advanced properties of
* the object such as its transformation matrix. </p>
*
* <p>DisplayObject is an abstract base class; therefore, you cannot call
* DisplayObject directly. Invoking <code>new DisplayObject()</code> throws an
* <code>ArgumentError</code> exception. </p>
*
* <p>All display objects inherit from the DisplayObject class.</p>
*
* <p>The DisplayObject class itself does not include any APIs for rendering
* content onscreen. For that reason, if you want create a custom subclass of
* the DisplayObject class, you will want to extend one of its subclasses that
* do have APIs for rendering content onscreen, such as the Shape, Sprite,
* Bitmap, SimpleButton, TextField, or MovieClip class.</p>
*
* <p>The DisplayObject class contains several broadcast events. Normally, the
* target of any particular event is a specific DisplayObject instance. For
* example, the target of an <code>added</code> event is the specific
* DisplayObject instance that was added to the display list. Having a single
* target restricts the placement of event listeners to that target and in
* some cases the target's ancestors on the display list. With broadcast
* events, however, the target is not a specific DisplayObject instance, but
* rather all DisplayObject instances, including those that are not on the
* display list. This means that you can add a listener to any DisplayObject
* instance to listen for broadcast events. In addition to the broadcast
* events listed in the DisplayObject class's Events table, the DisplayObject
* class also inherits two broadcast events from the EventDispatcher class:
* <code>activate</code> and <code>deactivate</code>.</p>
*
* <p>Some properties previously used in the ActionScript 1.0 and 2.0
* MovieClip, TextField, and Button classes(such as <code>_alpha</code>,
* <code>_height</code>, <code>_name</code>, <code>_width</code>,
* <code>_x</code>, <code>_y</code>, and others) have equivalents in the
* ActionScript 3.0 DisplayObject class that are renamed so that they no
* longer begin with the underscore(_) character.</p>
*
* <p>For more information, see the "Display Programming" chapter of the
* <i>ActionScript 3.0 Developer's Guide</i>.</p>
*
* @event added Dispatched when a display object is added to the
* display list. The following methods trigger this
* event:
* <code>DisplayObjectContainer.addChild()</code>,
* <code>DisplayObjectContainer.addChildAt()</code>.
* @event addedToScene Dispatched when a display object is added to the on
* scene display list, either directly or through the
* addition of a sub tree in which the display object
* is contained. The following methods trigger this
* event:
* <code>DisplayObjectContainer.addChild()</code>,
* <code>DisplayObjectContainer.addChildAt()</code>.
* @event enterFrame [broadcast event] Dispatched when the playhead is
* entering a new frame. If the playhead is not
* moving, or if there is only one frame, this event
* is dispatched continuously in conjunction with the
* frame rate. This event is a broadcast event, which
* means that it is dispatched by all display objects
* with a listener registered for this event.
* @event exitFrame [broadcast event] Dispatched when the playhead is
* exiting the current frame. All frame scripts have
* been run. If the playhead is not moving, or if
* there is only one frame, this event is dispatched
* continuously in conjunction with the frame rate.
* This event is a broadcast event, which means that
* it is dispatched by all display objects with a
* listener registered for this event.
* @event frameConstructed [broadcast event] Dispatched after the constructors
* of frame display objects have run but before frame
* scripts have run. If the playhead is not moving, or
* if there is only one frame, this event is
* dispatched continuously in conjunction with the
* frame rate. This event is a broadcast event, which
* means that it is dispatched by all display objects
* with a listener registered for this event.
* @event removed Dispatched when a display object is about to be
* removed from the display list. Two methods of the
* DisplayObjectContainer class generate this event:
* <code>removeChild()</code> and
* <code>removeChildAt()</code>.
*
* <p>The following methods of a
* DisplayObjectContainer object also generate this
* event if an object must be removed to make room for
* the new object: <code>addChild()</code>,
* <code>addChildAt()</code>, and
* <code>setChildIndex()</code>. </p>
* @event removedFromScene Dispatched when a display object is about to be
* removed from the display list, either directly or
* through the removal of a sub tree in which the
* display object is contained. Two methods of the
* DisplayObjectContainer class generate this event:
* <code>removeChild()</code> and
* <code>removeChildAt()</code>.
*
* <p>The following methods of a
* DisplayObjectContainer object also generate this
* event if an object must be removed to make room for
* the new object: <code>addChild()</code>,
* <code>addChildAt()</code>, and
* <code>setChildIndex()</code>. </p>
* @event render [broadcast event] Dispatched when the display list
* is about to be updated and rendered. This event
* provides the last opportunity for objects listening
* for this event to make changes before the display
* list is rendered. You must call the
* <code>invalidate()</code> method of the Scene
* object each time you want a <code>render</code>
* event to be dispatched. <code>Render</code> events
* are dispatched to an object only if there is mutual
* trust between it and the object that called
* <code>Scene.invalidate()</code>. This event is a
* broadcast event, which means that it is dispatched
* by all display objects with a listener registered
* for this event.
*
* <p><b>Note: </b>This event is not dispatched if the
* display is not rendering. This is the case when the
* content is either minimized or obscured. </p>
*/
var DisplayObject = (function (_super) {
__extends(DisplayObject, _super);
/**
* Creates a new <code>DisplayObject</code> instance.
*/
function DisplayObject() {
var _this = this;
_super.call(this);
this._queuedEvents = new Array();
this._boxBoundsInvalid = true;
this._sphereBoundsInvalid = true;
this._pSceneTransform = new Matrix3D_1.default();
this._pIsEntity = false;
this._pIsContainer = false;
this._sessionID = -1;
this._depthID = -16384;
this._inverseSceneTransform = new Matrix3D_1.default();
this._scenePosition = new Vector3D_1.default();
this._explicitVisibility = true;
this._explicitMaskId = -1;
this._pImplicitVisibility = true;
this._pImplicitMaskId = -1;
this._pImplicitMaskIds = new Array();
this._explicitMouseEnabled = true;
this._pImplicitMouseEnabled = true;
this._orientationMatrix = new Matrix3D_1.default();
this._inheritColorTransform = false;
this._maskMode = false;
//temp vector used in global to local
this._tempVector3D = new Vector3D_1.default();
/**
*
*/
this.alignmentMode = AlignmentMode_1.default.REGISTRATION_POINT;
/**
*
*/
this.castsShadows = true;
/**
*
*/
this.orientationMode = OrientationMode_1.default.DEFAULT;
/**
*
*/
this.zOffset = 0;
//creation of associated transform object
this._transform = new Transform_1.default();
//setup transform listeners
this._transform.addEventListener(TransformEvent_1.default.INVALIDATE_MATRIX3D, function (event) { return _this._onInvalidateMatrix3D(event); });
this._transform.addEventListener(TransformEvent_1.default.INVALIDATE_COLOR_TRANSFORM, function (event) { return _this._onInvalidateColorTransform(event); });
//default bounds type
this._boundsType = BoundsType_1.default.AXIS_ALIGNED_BOX;
}
Object.defineProperty(DisplayObject.prototype, "adapter", {
/**
* adapter is used to provide MovieClip to scripts taken from different platforms
* setter typically managed by factory
*/
get: function () {
return this._adapter;
},
set: function (value) {
this._adapter = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "inheritColorTransform", {
get: function () {
return this._inheritColorTransform;
},
set: function (value) {
if (this._inheritColorTransform == value)
return;
this._inheritColorTransform = value;
this.pInvalidateHierarchicalProperties(HierarchicalProperties_1.default.COLOR_TRANSFORM);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "alpha", {
/**
* Indicates the alpha transparency value of the object specified. Valid
* values are 0(fully transparent) to 1(fully opaque). The default value is
* 1. Display objects with <code>alpha</code> set to 0 <i>are</i> active,
* even though they are invisible.
*/
get: function () {
return this._transform.colorTransform ? this._transform.colorTransform.alphaMultiplier : 1;
},
set: function (value) {
if (!this._transform.colorTransform)
this._transform.colorTransform = new ColorTransform_1.default();
this._transform.colorTransform.alphaMultiplier = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "boundsType", {
/**
*
*/
get: function () {
return this._boundsType;
},
set: function (value) {
if (this._boundsType == value)
return;
this._boundsType = value;
this.invalidate();
this._pInvalidateBounds();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "depth", {
/**
* Indicates the depth of the display object, in pixels. The depth is
* calculated based on the bounds of the content of the display object. When
* you set the <code>depth</code> property, the <code>scaleZ</code> property
* is adjusted accordingly, as shown in the following code:
*
* <p>Except for TextField and Video objects, a display object with no
* content (such as an empty sprite) has a depth of 0, even if you try to
* set <code>depth</code> to a different value.</p>
*/
get: function () {
return this.getBox().depth * this.scaleZ;
},
set: function (val) {
if (this._depth == val)
return;
this._depth = val;
this._setScaleZ(val / this.getBox().depth);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "eulers", {
/**
* Defines the rotation of the 3d object as a <code>Vector3D</code> object containing euler angles for rotation around x, y and z axis.
*/
get: function () {
if (!this._eulers)
this._eulers = new Vector3D_1.default();
this._eulers.x = this.rotationX;
this._eulers.y = this.rotationY;
this._eulers.z = this.rotationZ;
return this._eulers;
},
set: function (value) {
this.rotationX = value.x;
this.rotationY = value.y;
this.rotationZ = value.z;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "height", {
/**
* An indexed array that contains each filter object currently associated
* with the display object. The flash.filters package contains several
* classes that define specific filters you can use.
*
* <p>Filters can be applied in Flash Professional at design time, or at run
* time by using ActionScript code. To apply a filter by using ActionScript,
* you must make a temporary copy of the entire <code>filters</code> array,
* modify the temporary array, then assign the value of the temporary array
* back to the <code>filters</code> array. You cannot directly add a new
* filter object to the <code>filters</code> array.</p>
*
* <p>To add a filter by using ActionScript, perform the following steps
* (assume that the target display object is named
* <code>myDisplayObject</code>):</p>
*
* <ol>
* <li>Create a new filter object by using the constructor method of your
* chosen filter class.</li>
* <li>Assign the value of the <code>myDisplayObject.filters</code> array
* to a temporary array, such as one named <code>myFilters</code>.</li>
* <li>Add the new filter object to the <code>myFilters</code> temporary
* array.</li>
* <li>Assign the value of the temporary array to the
* <code>myDisplayObject.filters</code> array.</li>
* </ol>
*
* <p>If the <code>filters</code> array is undefined, you do not need to use
* a temporary array. Instead, you can directly assign an array literal that
* contains one or more filter objects that you create. The first example in
* the Examples section adds a drop shadow filter by using code that handles
* both defined and undefined <code>filters</code> arrays.</p>
*
* <p>To modify an existing filter object, you must use the technique of
* modifying a copy of the <code>filters</code> array:</p>
*
* <ol>
* <li>Assign the value of the <code>filters</code> array to a temporary
* array, such as one named <code>myFilters</code>.</li>
* <li>Modify the property by using the temporary array,
* <code>myFilters</code>. For example, to set the quality property of the
* first filter in the array, you could use the following code:
* <code>myFilters[0].quality = 1;</code></li>
* <li>Assign the value of the temporary array to the <code>filters</code>
* array.</li>
* </ol>
*
* <p>At load time, if a display object has an associated filter, it is
* marked to cache itself as a transparent bitmap. From this point forward,
* as long as the display object has a valid filter list, the player caches
* the display object as a bitmap. This source bitmap is used as a source
* image for the filter effects. Each display object usually has two bitmaps:
* one with the original unfiltered source display object and another for the
* final image after filtering. The final image is used when rendering. As
* long as the display object does not change, the final image does not need
* updating.</p>
*
* <p>The flash.filters package includes classes for filters. For example, to
* create a DropShadow filter, you would write:</p>
*
* @throws ArgumentError When <code>filters</code> includes a ShaderFilter
* and the shader output type is not compatible with
* this operation(the shader must specify a
* <code>pixel4</code> output).
* @throws ArgumentError When <code>filters</code> includes a ShaderFilter
* and the shader doesn't specify any image input or
* the first input is not an <code>image4</code> input.
* @throws ArgumentError When <code>filters</code> includes a ShaderFilter
* and the shader specifies an image input that isn't
* provided.
* @throws ArgumentError When <code>filters</code> includes a ShaderFilter, a
* ByteArray or Vector.<Number> instance as a shader
* input, and the <code>width</code> and
* <code>height</code> properties aren't specified for
* the ShaderInput object, or the specified values
* don't match the amount of data in the input data.
* See the <code>ShaderInput.input</code> property for
* more information.
*/
// public filters:Array<Dynamic>;
/**
* Indicates the height of the display object, in pixels. The height is
* calculated based on the bounds of the content of the display object. When
* you set the <code>height</code> property, the <code>scaleY</code> property
* is adjusted accordingly, as shown in the following code:
*
* <p>Except for TextField and Video objects, a display object with no
* content (such as an empty sprite) has a height of 0, even if you try to
* set <code>height</code> to a different value.</p>
*/
get: function () {
return this.getBox().height * this.scaleY;
},
set: function (val) {
if (this._height == val)
return;
this._height = val;
this._setScaleY(val / this.getBox().height);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "index", {
/**
* Indicates the instance container index of the DisplayObject. The object can be
* identified in the child list of its parent display object container by
* calling the <code>getChildByIndex()</code> method of the display object
* container.
*
* <p>If the DisplayObject has no parent container, index defaults to 0.</p>
*/
get: function () {
if (this._pParent)
return this._pParent.getChildIndex(this);
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "inverseSceneTransform", {
/**
*
*/
get: function () {
if (this._inverseSceneTransformDirty) {
this._inverseSceneTransform.copyFrom(this.sceneTransform);
this._inverseSceneTransform.invert();
this._inverseSceneTransformDirty = false;
}
return this._inverseSceneTransform;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "isEntity", {
/**
*
*/
get: function () {
return this._pIsEntity;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "isContainer", {
/**
*
*/
get: function () {
return this._pIsContainer;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "loaderInfo", {
/**
* Returns a LoaderInfo object containing information about loading the file
* to which this display object belongs. The <code>loaderInfo</code> property
* is defined only for the root display object of a SWF file or for a loaded
* Bitmap(not for a Bitmap that is drawn with ActionScript). To find the
* <code>loaderInfo</code> object associated with the SWF file that contains
* a display object named <code>myDisplayObject</code>, use
* <code>myDisplayObject.root.loaderInfo</code>.
*
* <p>A large SWF file can monitor its download by calling
* <code>this.root.loaderInfo.addEventListener(Event.COMPLETE,
* func)</code>.</p>
*/
get: function () {
return this._loaderInfo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "maskMode", {
get: function () {
return this._maskMode;
},
set: function (value) {
if (this._maskMode == value)
return;
this._maskMode = value;
this._explicitMaskId = value ? this.id : -1;
this._updateMaskMode();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "mouseEnabled", {
/**
* Specifies whether this object receives mouse, or other user input,
* messages. The default value is <code>true</code>, which means that by
* default any InteractiveObject instance that is on the display list
* receives mouse events or other user input events. If
* <code>mouseEnabled</code> is set to <code>false</code>, the instance does
* not receive any mouse events(or other user input events like keyboard
* events). Any children of this instance on the display list are not
* affected. To change the <code>mouseEnabled</code> behavior for all
* children of an object on the display list, use
* <code>flash.display.DisplayObjectContainer.mouseChildren</code>.
*
* <p> No event is dispatched by setting this property. You must use the
* <code>addEventListener()</code> method to create interactive
* functionality.</p>
*/
get: function () {
return this._explicitMouseEnabled;
},
set: function (value) {
if (this._explicitMouseEnabled == value)
return;
this._explicitMouseEnabled = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "mouseX", {
/**
* Indicates the x coordinate of the mouse or user input device position, in
* pixels.
*
* <p><b>Note</b>: For a DisplayObject that has been rotated, the returned x
* coordinate will reflect the non-rotated object.</p>
*/
get: function () {
return this._mouseX;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "mouseY", {
/**
* Indicates the y coordinate of the mouse or user input device position, in
* pixels.
*
* <p><b>Note</b>: For a DisplayObject that has been rotated, the returned y
* coordinate will reflect the non-rotated object.</p>
*/
get: function () {
return this._mouseY;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "name", {
/**
* Indicates the instance name of the DisplayObject. The object can be
* identified in the child list of its parent display object container by
* calling the <code>getChildByName()</code> method of the display object
* container.
*
* @throws IllegalOperationError If you are attempting to set this property
* on an object that was placed on the timeline
* in the Flash authoring tool.
*/
get: function () {
return this._pName;
},
set: function (value) {
this._pName = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "parent", {
/**
* Indicates the DisplayObjectContainer object that contains this display
* object. Use the <code>parent</code> property to specify a relative path to
* display objects that are above the current display object in the display
* list hierarchy.
*
* <p>You can use <code>parent</code> to move up multiple levels in the
* display list as in the following:</p>
*
* @throws SecurityError The parent display object belongs to a security
* sandbox to which you do not have access. You can
* avoid this situation by having the parent movie call
* the <code>Security.allowDomain()</code> method.
*/
get: function () {
return this._pParent;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "partition", {
/**
*
*/
get: function () {
return this._explicitPartition;
},
set: function (value) {
if (this._explicitPartition == value)
return;
this._explicitPartition = value;
this._iSetScene(this._pScene, this._pParent ? this._pParent._iAssignedPartition : null);
this.dispatchEvent(new DisplayObjectEvent_1.default(DisplayObjectEvent_1.default.PARTITION_CHANGED, this));
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "pivot", {
/**
* Defines the local point around which the object rotates.
*/
get: function () {
return this._pivot;
},
set: function (pivot) {
if (this._pivot && this._pivot.x == pivot.x && this._pivot.y == pivot.y && this._pivot.z == pivot.z)
return;
if (!pivot) {
this._pivot = null;
this._pivotScale = null;
}
else {
if (!this._pivot)
this._pivot = new Vector3D_1.default();
this._pivot.x = pivot.x;
this._pivot.y = pivot.y;
this._pivot.z = pivot.z;
}
this.pInvalidateHierarchicalProperties(HierarchicalProperties_1.default.SCENE_TRANSFORM);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "root", {
/**
* For a display object in a loaded SWF file, the <code>root</code> property
* is the top-most display object in the portion of the display list's tree
* structure represented by that SWF file. For a Bitmap object representing a
* loaded image file, the <code>root</code> property is the Bitmap object
* itself. For the instance of the main class of the first SWF file loaded,
* the <code>root</code> property is the display object itself. The
* <code>root</code> property of the Scene object is the Scene object itself.
* The <code>root</code> property is set to <code>null</code> for any display
* object that has not been added to the display list, unless it has been
* added to a display object container that is off the display list but that
* is a child of the top-most display object in a loaded SWF file.
*
* <p>For example, if you create a new Sprite object by calling the
* <code>Sprite()</code> constructor method, its <code>root</code> property
* is <code>null</code> until you add it to the display list(or to a display
* object container that is off the display list but that is a child of the
* top-most display object in a SWF file).</p>
*
* <p>For a loaded SWF file, even though the Loader object used to load the
* file may not be on the display list, the top-most display object in the
* SWF file has its <code>root</code> property set to itself. The Loader
* object does not have its <code>root</code> property set until it is added
* as a child of a display object for which the <code>root</code> property is
* set.</p>
*/
get: function () {
return this._root;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "rotationX", {
/**
* Indicates the x-axis rotation of the DisplayObject instance, in degrees,
* from its original orientation relative to the 3D parent container. Values
* from 0 to 180 represent clockwise rotation; values from 0 to -180
* represent counterclockwise rotation. Values outside this range are added
* to or subtracted from 360 to obtain a value within the range.
*/
get: function () {
return this._transform.rotation.x * MathConsts_1.default.RADIANS_TO_DEGREES;
},
set: function (val) {
if (this.rotationX == val)
return;
this._transform.rotation.x = val * MathConsts_1.default.DEGREES_TO_RADIANS;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "rotationY", {
/**
* Indicates the y-axis rotation of the DisplayObject instance, in degrees,
* from its original orientation relative to the 3D parent container. Values
* from 0 to 180 represent clockwise rotation; values from 0 to -180
* represent counterclockwise rotation. Values outside this range are added
* to or subtracted from 360 to obtain a value within the range.
*/
get: function () {
return this._transform.rotation.y * MathConsts_1.default.RADIANS_TO_DEGREES;
},
set: function (val) {
if (this.rotationY == val)
return;
this._transform.rotation.y = val * MathConsts_1.default.DEGREES_TO_RADIANS;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "rotationZ", {
/**
* Indicates the z-axis rotation of the DisplayObject instance, in degrees,
* from its original orientation relative to the 3D parent container. Values
* from 0 to 180 represent clockwise rotation; values from 0 to -180
* represent counterclockwise rotation. Values outside this range are added
* to or subtracted from 360 to obtain a value within the range.
*/
get: function () {
return this._transform.rotation.z * MathConsts_1.default.RADIANS_TO_DEGREES;
},
set: function (val) {
if (this.rotationZ == val)
return;
this._transform.rotation.z = val * MathConsts_1.default.DEGREES_TO_RADIANS;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "scaleX", {
/**
* Indicates the horizontal scale(percentage) of the object as applied from
* the registration point. The default registration point is(0,0). 1.0
* equals 100% scale.
*
* <p>Scaling the local coordinate system changes the <code>x</code> and
* <code>y</code> property values, which are defined in whole pixels. </p>
*/
get: function () {
return this._transform.scale.x;
},
set: function (val) {
//remove absolute width
this._width = null;
this._setScaleX(val);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "scaleY", {
/**
* Indicates the vertical scale(percentage) of an object as applied from the
* registration point of the object. The default registration point is(0,0).
* 1.0 is 100% scale.
*
* <p>Scaling the local coordinate system changes the <code>x</code> and
* <code>y</code> property values, which are defined in whole pixels. </p>
*/
get: function () {
return this._transform.scale.y;
},
set: function (val) {
//remove absolute height
this._height = null;
this._setScaleY(val);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "scaleZ", {
/**
* Indicates the depth scale(percentage) of an object as applied from the
* registration point of the object. The default registration point is(0,0).
* 1.0 is 100% scale.
*
* <p>Scaling the local coordinate system changes the <code>x</code>,
* <code>y</code> and <code>z</code> property values, which are defined in
* whole pixels. </p>
*/
get: function () {
return this._transform.scale.z;
},
set: function (val) {
//remove absolute depth
this._depth = null;
this._setScaleZ(val);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "skewX", {
/**
* Indicates the horizontal skew(angle) of the object as applied from
* the registration point. The default registration point is(0,0).
*/
get: function () {
return this._transform.skew.x;
},
set: function (val) {
if (this.skewX == val)
return;
this._transform.skew.x = val;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "skewY", {
/**
* Indicates the vertical skew(angle) of an object as applied from the
* registration point of the object. The default registration point is(0,0).
*/
get: function () {
return this._transform.skew.y;
},
set: function (val) {
if (this.skewY == val)
return;
this._transform.skew.y = val;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "skewZ", {
/**
* Indicates the depth skew(angle) of an object as applied from the
* registration point of the object. The default registration point is(0,0).
*/
get: function () {
return this._transform.skew.z;
},
set: function (val) {
if (this.skewZ == val)
return;
this._transform.skew.z = val;
this._transform.invalidateMatrix3D();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "scene", {
/**
*
*/
get: function () {
return this._pScene;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "scenePosition", {
/**
*
*/
get: function () {
if (this._scenePositionDirty) {
if (this._pivot && this.alignmentMode == AlignmentMode_1.default.PIVOT_POINT) {
this._scenePosition = this.sceneTransform.transformVector(this._pivotScale);
}
else {
this.sceneTransform.copyColumnTo(3, this._scenePosition);
}
this._scenePositionDirty = false;
}
return this._scenePosition;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "sceneTransform", {
get: function () {
if (this._hierarchicalPropsDirty & HierarchicalProperties_1.default.SCENE_TRANSFORM)
this.pUpdateSceneTransform();
return this._pSceneTransform;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "shaderPickingDetails", {
/**
*
*/
get: function () {
return this._shaderPickingDetails;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "debugVisible", {
/**
*
*/
get: function () {
return this._debugVisible;
},
set: function (value) {
if (value == this._debugVisible)
return;
this._debugVisible = value;
this.invalidate();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "transform", {
/**
* An object with properties pertaining to a display object's matrix, color
* transform, and pixel bounds. The specific properties - matrix,
* colorTransform, and three read-only properties
* (<code>concatenatedMatrix</code>, <code>concatenatedColorTransform</code>,
* and <code>pixelBounds</code>) - are described in the entry for the
* Transform class.
*
* <p>Each of the transform object's properties is itself an object. This
* concept is important because the only way to set new values for the matrix
* or colorTransform objects is to create a new object and copy that object
* into the transform.matrix or transform.colorTransform property.</p>
*
* <p>For example, to increase the <code>tx</code> value of a display
* object's matrix, you must make a copy of the entire matrix object, then
* copy the new object into the matrix property of the transform object:</p>
* <pre xml:space="preserve"><code> public myMatrix:Matrix =
* myDisplayObject.transform.matrix; myMatrix.tx += 10;
* myDisplayObject.transform.matrix = myMatrix; </code></pre>
*
* <p>You cannot directly set the <code>tx</code> property. The following
* code has no effect on <code>myDisplayObject</code>: </p>
* <pre xml:space="preserve"><code> myDisplayObject.transform.matrix.tx +=
* 10; </code></pre>
*
* <p>You can also copy an entire transform object and assign it to another
* display object's transform property. For example, the following code
* copies the entire transform object from <code>myOldDisplayObj</code> to
* <code>myNewDisplayObj</code>:</p>
* <code>myNewDisplayObj.transform = myOldDisplayObj.transform;</code>
*
* <p>The resulting display object, <code>myNewDisplayObj</code>, now has the
* same values for its matrix, color transform, and pixel bounds as the old
* display object, <code>myOldDisplayObj</code>.</p>
*
* <p>Note that AIR for TV devices use hardware acceleration, if it is
* available, for color transforms.</p>
*/
get: function () {
return this._transform;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "visible", {
/**
* Whether or not the display object is visible. Display objects that are not
* visible are disabled. For example, if <code>visible=false</code> for an
* InteractiveObject instance, it cannot be clicked.
*/
get: function () {
return this._explicitVisibility;
},
set: function (value) {
if (this._explicitVisibility == value)
return;
this._explicitVisibility = value;
this.pInvalidateHierarchicalProperties(HierarchicalProperties_1.default.VISIBLE);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "masks", {
get: function () {
return this._explicitMasks;
},
set: function (value) {
if (this._explicitMasks == value)
return;
this._explicitMasks = value;
//make sure maskMode is set to true for all masks
if (value != null && value.length) {
var len = value.length;
for (var i = 0; i < len; i++)
value[i].maskMode = true;
}
this.pInvalidateHierarchicalProperties(HierarchicalProperties_1.default.MASKS);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "width", {
/**
* Indicates the width of the display object, in pixels. The width is
* calculated based on the bounds of the content of the display object. When
* you set the <code>width</code> property, the <code>scaleX</code> property
* is adjusted accordingly, as shown in the following code:
*
* <p>Except for TextField and Video objects, a display object with no
* content(such as an empty sprite) has a width of 0, even if you try to set
* <code>width</code> to a different value.</p>
*/
get: function () {
return this.getBox().width * this.scaleX;
},
set: function (val) {
if (this._width == val)
return;
this._width = val;
this._setScaleX(val / this.getBox().width);
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "x", {
/**
* Indicates the <i>x</i> coordinate of the DisplayObject instance relative
* to the local coordinates of the parent DisplayObjectContainer. If the
* object is inside a DisplayObjectContainer that has transformations, it is
* in the local coordinate system of the enclosing DisplayObjectContainer.
* Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
* DisplayObjectContainer's children inherit a coordinate system that is
* rotated 90° counterclockwise. The object's coordinates refer to the
* registration point position.
*/
get: function () {
return this._transform.position.x;
},
set: function (val) {
if (this._transform.position.x == val)
return;
this._transform.matrix3D.rawData[12] = val;
this._transform.invalidatePosition();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "y", {
/**
* Indicates the <i>y</i> coordinate of the DisplayObject instance relative
* to the local coordinates of the parent DisplayObjectContainer. If the
* object is inside a DisplayObjectContainer that has transformations, it is
* in the local coordinate system of the enclosing DisplayObjectContainer.
* Thus, for a DisplayObjectContainer rotated 90° counterclockwise, the
* DisplayObjectContainer's children inherit a coordinate system that is
* rotated 90° counterclockwise. The object's coordinates refer to the
* registration point position.
*/
get: function () {
return this._transform.position.y;
},
set: function (val) {
if (this._transform.position.y == val)
return;
this._transform.matrix3D.rawData[13] = val;
this._transform.invalidatePosition();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DisplayObject.prototype, "z", {
/**
* Indicates the z coordinate position along the z-axis of the DisplayObject
* instance relative to the 3D parent container. The z property is used for
* 3D coordinates, not screen or pixel coordinates.
*
* <p>When you set a <code>z</code> property for a display object to
* something other than the default value of <code>0</code>, a corresponding
* Matrix3D object is automatically created. for adjusting a display object's
* position and orientation in three dimensions. When working with the
* z-axis, the existing behavior of x and y properties changes from screen or
* pixel coordinates to positions relative to the 3D parent container.</p>
*
* <p>For example, a child of the <code>_root</code> at position x = 100, y =
* 100, z = 200 is not drawn at pixel location(100,100). The child is drawn
* wherever the 3D projection calculation puts it. The calculation is:</p>
*
* <p><code>(x~~cameraFocalLength/cameraRelativeZPosition,
* y~~cameraFocalLength/cameraRelativeZPosition)</code></p>
*/
get: function () {
return this._transform.position.z;
},
set: function (val) {
if (this._transform.position.z == val)
return;
this._transform.matrix3D.rawData[14] = val;
this._transform.invalidatePosition();
},
enumerable: true,
configurable: true
});
/**
*
*/
DisplayObject.prototype.addEventListener = function (type, listener) {
_super.prototype.addEventListener.call(this, type, listener);
switch (type) {
case DisplayObjectEvent_1.default.SCENE_CHANGED:
this._listenToSceneChanged = true;
break;
case DisplayObjectEvent_1.default.SCENETRANSFORM_CHANGED:
this._listenToSceneTransfor