DisplayObject

DisplayObject

new DisplayObject()

The DisplayObject constructor. It's the base class for everything that's displayable.
Properties:
Name Type Description
id number The unique id of the DisplayObject instance.
__supportedAttributes__ __list__ List of supported attribute names. These are the attribute names you can pass to the attr() method. Note that this property is not available in your code, it's just here for documentation purposes.
Properties
Name Type Description
matrix module:matrix.Matrix The transformation matrix
opacity number The opacity of the object.
origin number The transformation origin
rotation number The rotation in radians
scale number (Setter only) Sets scaleX and scaleY
scaleX number The scale applied to the x-axis.
scaleY number The scale applied to the y-axis.
x number Sets the matrix offset on the x-axis.
y number Sets the matrix offset on the y-axis.
filters array The list of filters applied to the DisplayObject

Mixes In

Members

<static> parent :DisplayList|null

The display list this display object is part of.
Type:

<static> type

The type of the given instance. This is used to send as part of the render message. Each inheriting primitive must override this.

Methods

<static> _activate()

To be called by the parent when adding a display object or one of its ancestors to the stage

<static> _deactivate()

To be called by the parent when removing a display objector one of its ancestors from the stage.

<static> addAfter(sibling) → {this}

Adds this instance to the reference object's parent right after the reference object. NOTE: The passed reference object must be already added for this method to work.
Parameters:
Name Type Description
sibling DisplayObject
Returns:
Type
this

<static> addBefore(sibling) → {this}

Adds this instance to the reference object's parent right before the reference object. NOTE: The passed reference object must be already added for this method to work.
Parameters:
Name Type Description
sibling DisplayObject
Returns:
Type
this

<static> addTo(parent) → {this}

Adds this instance to a parent on top of all parent's children.
Parameters:
Name Type Description
parent DisplayList
Returns:
Type
this

<static> animate(duration, properties, options) → {this}

Animates object by specified properties
Parameters:
Name Type Argument Description
duration Number | String The duration, either as frames (number), seconds (e.g. '1s'), milliseconds (e.g. '100ms') or as a percentage of the clock's total frames (e.g. '23%')
properties Object The properties/values to animate
options Object <optional>
Additional options
Properties
Name Type Argument Default Description
easing String | Function <optional>
Easing function. Either the name of a predefined or a custom function
delay Number | String <optional>
0 Delay before animation begins, in frames or seconds
repeat Number <optional>
0 The number of repetitions.
Returns:
the instance
Type
this

<static> attr(attr, value) → {this|mixed}

Sets or gets an attribute / multiple attributes on / from the object. When called without parameters: returns an object with all attributes as key / value pairs. When called with one parameter: if parameter is an object, sets all properties as attributes on the instance. Gets an attribute otherwise. When called with two parameters: Sets a single attribute to a value.
Parameters:
Name Type Argument Description
attr string | Object <optional>
If string: single attribute mode. If object, sets multiple attributes from the object properties.
value mixed <optional>
If `attr` parameter is string: Sets the attribute to this value.
Returns:
The instance if setting, else attribute value(s).
Type
this | mixed
Example
o.attr('foo', 1); // sets the 'foo' attribute
o.attr('foo'); // gets the 'foo' attribute
o.attr({foo: 1, bar: 'baz'}); // sets the 'foo' and 'bar' attributes
o.attr(); // gets all attributes
Supported attributes are:
 - matrix: {module:matrix.Matrix}
 - opacity: {number}
 - origin: {number}
 - rotation: {number}
 - scale: {number}
 - scaleX: {number}
 - scaleY: {number}
 - x: {number}
 - y: {number}

<static> blendMode(blendMode) → {this|DisplayObject|null}

Gets or sets the blend mode for the display object. If called with parameter, the blendMode is set. When called without parameter, the currently used blendMode is returned. Call the method with null or undefined as parameter to reset the to its default blendMode (normal).
Parameters:
Name Type Argument Description
blendMode String | null <optional>
The blendMode to apply to the instance
Returns:
the instance if called with parameter, else the blendMode in use.
Type
this | DisplayObject | null

<static> composeRenderMessage() → {object}

Composes a message for the renderer
Returns:
The message
Type
object

<static> destroy() → {this}

Destroys a child: removes it from the parent and removes all listeners.
Returns:
The instance
Type
this

<static> getAbsoluteBoundingBox() → {Object}

Computed the absolute bounding box relative to the top-most ancestor
Returns:
an object with all box properties (left, top, right, bottom, width, height)
Type
Object

<static> getAbsoluteMatrix() → {Matrix}

Gets the matrix of the DisplayObject combined with all ancestor matrices
Returns:
The resulting matrix
Type
Matrix

<static> getBoundingBox(transform) → {Object}

Computes bounding boxes and single data points of a display object.
Parameters:
Name Type Argument Default Description
transform Matrix <optional>
null A transform to apply to all points before computation.
Returns:
an object with all box properties (left, top, right, bottom, width, height)
Type
Object

<static> globalToLocal(point) → {Point}

Transforms a point in global coordinate space to the local coordinate space of the display object.
Parameters:
Name Type Description
point Point
Returns:
Type
Point

<static> localToGlobal(point) → {Point}

Transforms a point in the local coordinate space of the display object to the global coordinate space.
Parameters:
Name Type Description
point Point
Returns:
Type
Point

<static> markUpdate()

Marks the current instance for an update

<static> mask(mask) → {this|DisplayObject|null}

Gets or sets the mask for the display object. If called with parameter, the mask is set. When called without parameter, the currently used mask is returned. Call the method with null or undefined as parameter to unset the mask.
Parameters:
Name Type Argument Description
mask DisplayObject | null <optional>
The mask to apply to the instance
Returns:
the instance if called with parameter, else the mask in use.
Type
this | DisplayObject | null

<static> remove(removalStrategy) → {this}

Detaches a child from its parent
Parameters:
Name Type Argument Default Description
removalStrategy String <optional>
'changeIndexes' In default mode ('changeIndexes'), no gaps are left in the display list. If 'keepIndexes' is passed, the child will simply be deleted from the children array, leaving a gap.
Returns:
The instance
Type
this

<static> setOrigin(x, y) → {this}

Sets the origin attribute of the instance.
Parameters:
Name Type Description
x number
y number
To Do:
  • Add support for sugar like 'center'
Returns:
The instance
Type
this