API Documentation for: 0.6.0
Show:

Stage Class

Extends Container
Defined in: Stage:34
Module: EaselJS

A stage is the root level Container for a display list. Each time its Stage/tick method is called, it will render its display list to its target canvas.

Example

This example creates a stage, adds a child to it, then uses Ticker to update the child and redraw the stage using update.

 var stage = new createjs.Stage("canvasElementId");
 var image = new createjs.Bitmap("imagePath.png");
 createjs.Ticker.addEventListener("tick", handleTick);
 function handleTick(event) {
     bitmap.x += 10;
     stage.update();
 }

Constructor

Stage

(
  • canvas
)

Defined in Stage:34

Parameters:

  • canvas HTMLCanvasElement | String | Object

    A canvas object that the Stage will render to, or the string id of a canvas object in the current document.

Item Index

Methods

_applyFilters

() protected

_applyShadow

(
  • ctx
  • shadow
)
protected

Parameters:

  • ctx CanvasRenderingContext2D
  • shadow Shadow

_getElementRect

(
  • e
)
protected

Defined in _getElementRect:529

Parameters:

_getObjectsUnderPoint

(
  • x
  • y
  • arr
  • mouseEvents
)
Array protected

Parameters:

  • x Number
  • y Number
  • arr Array
  • mouseEvents Number

    A bitmask indicating which event types to look for. Bit 1 specifies press & click & double click, bit 2 specifies it should look for mouse over and mouse out. This implementation may change.

Returns:

_getPointerData

(
  • id
)
protected

Defined in _getPointerData:438

Parameters:

_handleDoubleClick

(
  • e
)
protected

Parameters:

_handleMouseDown

(
  • e
)
protected

Parameters:

_handleMouseMove

(
  • e
)
protected

Parameters:

_handleMouseUp

(
  • e
)
protected

Defined in _handleMouseUp:557

Parameters:

_handlePointerDown

(
  • id
  • e
  • x
  • y
)
protected

Parameters:

_handlePointerMove

(
  • id
  • e
  • pageX
  • pageY
)
protected

Parameters:

_handlePointerUp

(
  • id
  • e
  • clear
)
protected

Parameters:

_hasMouseHandler

(
  • typeMask
)
Boolean protected

Indicates whether the display object has a listener of the corresponding event types.

Parameters:

  • typeMask Number

    A bitmask indicating which event types to look for. Bit 1 specifies press & click & double click, bit 2 specifies it should look for mouse over and mouse out. This implementation may change.

Returns:

_testHit

(
  • ctx
)
Boolean protected

Inherited from DisplayObject: _testHit:949

Parameters:

  • ctx CanvasRenderingContext2D

Returns:

_testMouseOver

() protected

Defined in _testMouseOver:643

_tick

() protected

Inherited from DisplayObject but overwritten in _tick:443

_updatePointerPosition

(
  • id
  • pageX
  • pageY
)
protected

Parameters:

addChild

(
  • child
)
DisplayObject

Inherited from Container: addChild:138

Adds a child to the top of the display list. You can also add multiple children, such as "addChild(child1, child2, ...);". Returns the child that was added, or the last child if multiple children were added.

Example

 container.addChild(bitmapInstance, shapeInstance);

Parameters:

Returns:

DisplayObject: The child that was added, or the last child if multiple children were added.

addChildAt

(
  • child
  • index
)
DisplayObject

Inherited from Container: addChildAt:162

Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and setting its parent to this Container. You can also add multiple children, such as "addChildAt(child1, child2, ..., index);". The index must be between 0 and numChildren. For example, to add myShape under otherShape in the display list, you could use: container.addChildAt(myShape, container.getChildIndex(otherShape)). This would also bump otherShape's index up by one. Returns the last child that was added, or the last child if multiple children were added. Fails silently if the index is out of range.

Parameters:

Returns:

DisplayObject: The child that was added, or the last child if multiple children were added.

addEventListener

(
  • type
  • listener
)
Function | Object

Adds the specified event listener.

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    An object with a handleEvent method, or a function that will be called when the event is dispatched.

Returns:

Function | Object: Returns the listener for chaining or assignment.

cache

(
  • x
  • y
  • width
  • height
  • scale
)

Inherited from DisplayObject: cache:628

Draws the display object into a new canvas, which is then used for subsequent draws. For complex content that does not change frequently (ex. a Container with many children that do not move, or a complex vector Shape), this can provide for much faster rendering because the content does not need to be re-rendered each tick. The cached display object can be moved, rotated, faded, etc freely, however if it's content changes, you must manually update the cache by calling updateCache() or cache() again. You must specify the cache area via the x, y, w, and h parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates. For example if you defined a Shape that drew a circle at 0, 0 with a radius of 25, you could call myShape.cache(-25, -25, 50, 50) to cache the full shape.

Parameters:

  • x Number

    The x coordinate origin for the cache region.

  • y Number

    The y coordinate origin for the cache region.

  • width Number

    The width of the cache region.

  • height Number

    The height of the cache region.

  • scale Number

    Optional. The scale at which the cache will be created. For example, if you cache a vector shape using myShape.cache(0,0,100,100,2) then the resulting cacheCanvas will be 200x200 px. This lets you scale and rotate cached elements with greater fidelity. Default is 1.

clear

()

Defined in clear:297

Clears the target canvas. Useful if autoClear is set to false.

clone

() DisplayObject

Inherited from DisplayObject: clone:870

Returns a clone of this DisplayObject. Some properties that are specific to this instance's current context are reverted to their defaults (for example .parent).

Returns:

DisplayObject: A clone of the current DisplayObject instance.

cloneProps

(
  • o
)
protected

Inherited from DisplayObject: cloneProps:894

Parameters:

  • o DisplayObject

    The DisplayObject instance which will have properties from the current DisplayObject instance copied into.

contains

(
  • child
)
Boolean

Inherited from Container: contains:344

Returns true if the specified display object either is this container or is a descendent. (child, grandchild, etc) of this container.

Parameters:

Returns:

Boolean: true if the specified display object either is this container or is a descendent.

dispatchEvent

(
  • eventObj
  • [target]
)
Boolean

Dispatches the specified event.

Parameters:

  • eventObj Object | String

    An object with a "type" property, or a string type. If a string is used, dispatchEvent will contstruct a generic event object with "type" and "params" properties.

  • [target] Object optional

    The object to use as the target property of the event object. This will default to the dispatching object.

Returns:

Boolean: Returns true if any listener returned true.

draw

(
  • ctx
  • ignoreCache
)

Inherited from DisplayObject but overwritten in draw:110

Draws the display object into the specified context ignoring it's visible, alpha, shadow, and transform. Returns true if the draw was handled (useful for overriding functionality). NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas 2D context object to draw into.

  • ignoreCache Boolean

    Indicates whether the draw operation should ignore any current cache. For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).

enableDOMEvents

(
  • [enable=true]
)

Defined in enableDOMEvents:384

Enables or disables the event listeners that stage adds to DOM elements (window, document and canvas). It is good practice to disable events when disposing of a Stage instance, otherwise the stage will continue to receive events from the page.

Parameters:

  • [enable=true] Boolean optional

    Indicates whether to enable or disable the events. Default is true.

enableMouseOver

(
  • [frequency=20]
)

Defined in enableMouseOver:364

Enables or disables (by passing a frequency of 0) mouse over events (mouseover and mouseout) for this stage's display list. These events can be expensive to generate, so they are disabled by default, and the frequency of the events can be controlled independently of mouse move events via the optional frequency parameter.

Parameters:

  • [frequency=20] Number optional

    Optional param specifying the maximum number of times per second to broadcast mouse over/out events. Set to 0 to disable mouse over events completely. Maximum is 50. A lower frequency is less responsive, but uses less CPU.

getCacheDataURL.

()

Returns a data URL for the cache, or null if this display object is not cached. Uses cacheID to ensure a new data URL is not generated if the cache has not changed.

getChildAt

(
  • index
)
DisplayObject

Inherited from Container: getChildAt:239

Returns the child at the specified index.

Parameters:

  • index Number

    The index of the child to return.

Returns:

DisplayObject: The child at the specified index.

getChildByName

(
  • name
)
DisplayObject

Inherited from Container: getChildByName:249

Returns the child with the specified name.

Parameters:

  • name String

    The name of the child to return.

Returns:

DisplayObject: The child with the specified name.

getChildIndex

(
  • child
)
Number

Inherited from Container: getChildIndex:273

Returns the index of the specified child in the display list, or -1 if it is not in the display list.

Parameters:

Returns:

Number: The index of the specified child. -1 if the child is not found.

getConcatenatedMatrix

(
  • mtx
)
Matrix2D

Generates a concatenated Matrix2D object representing the combined transform of the display object and all of its parent Containers up to the highest level ancestor (usually the stage). This can be used to transform positions between coordinate spaces, such as with localToGlobal and globalToLocal.

Parameters:

  • mtx Matrix2D

    Optional. A Matrix2D object to populate with the calculated values. If null, a new Matrix object is returned.

Returns:

Matrix2D: a concatenated Matrix2D object representing the combined transform of the display object and all of its parent Containers up to the highest level ancestor (usually the stage).

getMatrix

(
  • matrix
)
Matrix2D

Inherited from DisplayObject: getMatrix:800

Returns a matrix based on this object's transform.

Parameters:

  • matrix Matrix2D

    Optional. A Matrix2D object to populate with the calculated values. If null, a new Matrix object is returned.

Returns:

Matrix2D: A matrix representing this display object's transform.

getNumChildren

() Number

Inherited from Container: getNumChildren:283

Returns the number of children in the display list.

Returns:

Number: The number of children in the display list.

getObjectsUnderPoint

(
  • x
  • y
)
Array

Returns an array of all display objects under the specified coordinates that are in this container's display list. This routine ignores any display objects with mouseEnabled set to false. The array will be sorted in order of visual depth, with the top-most display object at index 0. This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully. For example, if testing for objects under the mouse, test on tick (instead of on mousemove), and only if the mouse's position has changed.

Parameters:

  • x Number

    The x position in the container to test.

  • y Number

    The y position in the container to test.

Returns:

Array: An Array of DisplayObjects under the specified coordinates.

getObjectUnderPoint

(
  • x
  • y
)
DisplayObject

Similar to getObjectsUnderPoint(), but returns only the top-most display object. This runs significantly faster than getObjectsUnderPoint(), but is still an expensive operation. See getObjectsUnderPoint() for more information.

Parameters:

  • x Number

    The x position in the container to test.

  • y Number

    The y position in the container to test.

Returns:

DisplayObject: The top-most display object under the specified coordinates.

getStage

() Stage

Inherited from DisplayObject: getStage:702

Returns the stage that this display object will be rendered on, or null if it has not been added to one.

Returns:

Stage: The Stage instance that the display object is a descendent of. null if the DisplayObject has not been added to a Stage.

globalToLocal

(
  • x
  • y
)
Point

Transforms the specified x and y position from the global (stage) coordinate space to the coordinate space of the display object. For example, this could be used to determine the current mouse position within the display object. Returns a Point instance with x and y properties correlating to the transformed position in the display object's coordinate space.

Parameters:

  • x Number

    The x position on the stage to transform.

  • y Number

    The y position on the stage to transform.

Returns:

Point: A Point instance with x and y properties correlating to the transformed position in the display object's coordinate space.

hasEventListener

(
  • type
)
Boolean

Indicates whether there is at least one listener for the specified event type.

Parameters:

  • type String

    The string type of the event.

Returns:

Boolean: Returns true if there is at least one listener for the specified event.

hitTest

(
  • x
  • y
)
Boolean

Inherited from DisplayObject but overwritten in hitTest:359

Tests whether the display object intersects the specified local point (ie. draws a pixel with alpha > 0 at the specified position). This ignores the alpha, shadow and compositeOperation of the display object, and all transform properties including regX/Y.

Parameters:

  • x Number

    The x position to check in the display object's local coordinates.

  • y Number

    The y position to check in the display object's local coordinates.

Returns:

Boolean: A Boolean indicating whether there is a visible section of a DisplayObject that overlaps the specified coordinates.

initialize

(
  • canvas
)
protected

Inherited from EventDispatcher but overwritten in initialize:241

Initialization method.

Parameters:

  • canvas HTMLCanvasElement | String | Object

    A canvas object, or the string id of a canvas object in the current document.

isVisible

() Boolean

Inherited from DisplayObject but overwritten in isVisible:91

Returns true or false indicating whether the display object would be visible if drawn to a canvas. This does not account for whether it would be visible within the boundaries of the stage. NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Returns:

Boolean: Boolean indicating whether the display object would be visible if drawn to a canvas

localToGlobal

(
  • x
  • y
)
Point

Transforms the specified x and y position from the coordinate space of the display object to the global (stage) coordinate space. For example, this could be used to position an HTML label over a specific point on a nested display object. Returns a Point instance with x and y properties correlating to the transformed coordinates on the stage.

Parameters:

  • x Number

    The x position in the source display object to transform.

  • y Number

    The y position in the source display object to transform.

Returns:

Point: A Point instance with x and y properties correlating to the transformed coordinates on the stage.

localToLocal

(
  • x
  • y
  • target
)
Point

Transforms the specified x and y position from the coordinate space of this display object to the coordinate space of the target display object. Returns a Point instance with x and y properties correlating to the transformed position in the target's coordinate space. Effectively the same as calling var pt = this.localToGlobal(x, y); pt = target.globalToLocal(pt.x, pt.y);

Parameters:

  • x Number

    The x position in the source display object to transform.

  • y Number

    The y position on the stage to transform.

  • target DisplayObject

    The target display object to which the coordinates will be transformed.

Returns:

Point: Returns a Point instance with x and y properties correlating to the transformed position in the target's coordinate space.

removeAllChildren

()

Removes all children from the display list.

removeAllEventListeners

(
  • [type]
)

Removes all listeners for the specified type, or all listeners of all types.

Parameters:

  • [type] String optional

    The string type of the event. If omitted, all listeners for all types will be removed.

removeChild

(
  • child
)
Boolean

Inherited from Container: removeChild:188

Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is already known. You can also remove multiple children, such as "removeChild(child1, child2, ...);". Returns true if the child (or children) was removed, or false if it was not in the display list.

Parameters:

Returns:

Boolean: true if the child (or children) was removed, or false if it was not in the display list.

removeEventListener

(
  • type
  • listener
)

Removes the specified event listener.

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    The listener function or object.

set

(
  • props
)
DisplayObject

Inherited from DisplayObject: set:858

Provides a chainable shortcut method for setting a number of properties on a DisplayObject instance. Ex.
var shape = stage.addChild( new Shape() ).set({graphics:myGraphics, x:100, y:100, alpha:0.5});

Parameters:

  • props Object

    A generic object containing properties to copy to the DisplayObject instance.

Returns:

DisplayObject: Returns The DisplayObject instance the method is called on (useful for chaining calls.)

setChildIndex

(
  • child
  • index
)

Inherited from Container: setChildIndex:326

Changes the depth of the specified child. Fails silently if the child is not a child of this container, or the index is out of range.

Parameters:

setTransform

(
  • x
  • y
  • scaleX
  • scaleY
  • rotation
  • skewX
  • skewY
  • regX
  • regY
)
DisplayObject

Shortcut method to quickly set the transform properties on the display object. All parameters are optional. Omitted parameters will have the default value set (ex. 0 for x/y, 1 for scaleX/Y).

Parameters:

Returns:

DisplayObject: Returns this instance. Useful for chaining commands.

setupContext

(
  • ctx
)

Applies this display object's transformation, alpha, globalCompositeOperation, clipping path (mask), and shadow to the specified context. This is typically called prior to draw.

Parameters:

  • ctx CanvasRenderingContext2D

    The canvas 2D to update.

sortChildren

(
  • sortFunction
)

Inherited from Container: sortChildren:263

Performs an array sort operation on the child list.

Parameters:

  • sortFunction Function

    the function to use to sort the child list. See javascript's Array.sort documentation for details.

swapChildren

(
  • child1
  • child2
)

Inherited from Container: swapChildren:307

Swaps the specified children's depth in the display list. Fails silently if either child is not a child of this Container.

Parameters:

swapChildrenAt

(
  • index1
  • index2
)

Inherited from Container: swapChildrenAt:292

Swaps the children at the specified indexes. Fails silently if either index is out of range.

Parameters:

toDataURL

(
  • backgroundColor
  • mimeType
)
String

Defined in toDataURL:308

Returns a data url that contains a Base64-encoded image of the contents of the stage. The returned data url can be specified as the src value of an image element.

Parameters:

  • backgroundColor String

    The background color to be used for the generated image. The value can be any value HTML color value, including HEX colors, rgb and rgba. The default value is a transparent background.

  • mimeType String

    The MIME type of the image format to be create. The default is "image/png". If an unknown MIME type is passed in, or if the browser does not support the specified MIME type, the default value will be used.

Returns:

String: a Base64 encoded image.

toString

() String

Inherited from EventDispatcher but overwritten in toString:427

Returns a string representation of this object.

Returns:

String: a string representation of the instance.

uncache

()

Inherited from DisplayObject: uncache:681

Clears the current cache. See cache() for more information.

update

()

Defined in update:256

Each time the update method is called, the stage will tick any descendants exposing a tick method (ex. BitmapAnimation) and render its entire display list to the canvas. Any parameters passed to update will be passed on to any onTick handlers.

updateCache

(
  • compositeOperation
)

Inherited from DisplayObject: updateCache:658

Redraws the display object to its cache. Calling updateCache without an active cache will throw an error. If compositeOperation is null the current cache will be cleared prior to drawing. Otherwise the display object will be drawn over the existing cache using the specified compositeOperation.

Parameters:

Properties

_cacheDataURL

String protected

Default: null

_cacheDataURLID

Number protected

Default: 0

_cacheOffsetX

Number protected

Default: 0

_cacheOffsetY

Number protected

Default: 0

_cacheScale

Number protected

Inherited from DisplayObject: _cacheScale:523

Default: 1

_listeners

Object protected

Inherited from EventDispatcher: _listeners:90

_matrix

Matrix2D protected

Inherited from DisplayObject: _matrix:547

Default: null

_mouseOverIntervalID

Number protected

_pointerCount

Object private

Defined in _pointerCount:218

Number of active pointers.

_pointerCount

Object private

Defined in _pointerCount:210

Number of active pointers.

_pointerData

Object private

Defined in _pointerData:201

Holds objects with data for each active pointer id. Each object has the following properties: x, y, event, target, overTarget, overX, overY, inBounds

_snapToPixelEnabled

Boolean deprecated protected static

Defined in _snapToPixelEnabled:62

Deprecated: Hardware acceleration in modern browsers makes this unnecessary.

Default: false

alpha

Number

Inherited from DisplayObject: alpha:207

The alpha (transparency) for this display object. 0 is fully transparent, 1 is fully opaque.

Default: 1

autoClear

Boolean

Defined in autoClear:96

Indicates whether the stage should automatically clear the canvas before each render. You can set this to false to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for example).

Default: true

cacheCanvas

HTMLCanvasElement | Object

Inherited from DisplayObject: cacheCanvas:215

If a cache is active, this returns the canvas that holds the cached version of this display object. See cache() for more information. READ-ONLY.

Default: null

cacheID

Number

Inherited from DisplayObject: cacheID:453

Returns an ID number that uniquely identifies the current cache for this display object. This can be used to determine if the cache has changed since a previous check.

Default: 0

canvas

HTMLCanvasElement | Object

Defined in canvas:105

The canvas the stage will render to. Multiple stages can share a single canvas, but you must disable autoClear for all but the first stage that will be ticked (or they will clear each other's render).

children

Array

Inherited from Container: children:60

The array of children in the display list. You should usually use the child management methods such as addChild, removeChild, swapChildren, etc, rather than accessing this directly, but it is included for advanced users.

Default: null

compositeOperation

String

The composite operation indicates how the pixels of this display object will be composited with the elements behind it. If null, this property is inherited from the parent container. For more information, read the whatwg spec on compositing.

Default: null

cursor

String

Inherited from DisplayObject: cursor:484

A CSS cursor (ex. "pointer", "help", "text", etc) that will be displayed when the user hovers over this display object. You must enable mouseover events using the stage.enableMouseOver() method to use this property. If null it will use the default cursor.

Default: null

DisplayObject__tick

Function private

DisplayObject_draw

Function private

DisplayObject_initialize

Function private

Inherited from Container but overwritten in DisplayObject_initialize:234

filters

Array

Inherited from DisplayObject: filters:444

An array of Filter objects to apply to this display object. Filters are only applied / updated when cache() or updateCache() is called on the display object, and only apply to the area that is cached.

Default: null

handleEvent

Function

Defined in handleEvent:282

Default event handler that calls Stage.update() when a "tick" event is received. This allows you to register a Stage instance as a event listener on Ticker directly, using:

 Ticker.addEventListener("tick", myStage");

Note that if you subscribe to ticks using this pattern then the tick event object will be passed through to display object tick handlers, instead of delta and paused parameters.

hitArea

DisplayObject

Inherited from DisplayObject but overwritten in hitArea:192

The hitArea property is not supported for Stage.

Default: null

id

Number

Inherited from DisplayObject: id:224

Unique ID for this display object. Makes display objects easier for some uses.

Default: -1

mask

Shape

Inherited from DisplayObject: mask:462

A Shape instance that defines a vector mask (clipping path) for this display object. The shape's transformation will be applied relative to the display object's parent coordinates (as if it were a child of the parent).

Default: null

mouseEnabled

Boolean

Indicates whether to include this object when running Stage.getObjectsUnderPoint(), and thus for mouse interactions. Setting this to true for Containers will cause the Container to be returned (not its children) regardless of whether it's mouseChildren property is true.

Default: true

mouseInBounds

Boolean

Defined in mouseInBounds:166

Indicates whether the mouse is currently within the bounds of the canvas.

Default: false

mouseMoveOutside

Boolean

If true, mouse move events will continue to be called when the mouse leaves the target canvas. See mouseInBounds, and MouseEvent.x/y/rawX/rawY.

Default: false

mouseX

Number

Defined in mouseX:113

READ-ONLY. The current mouse X position on the canvas. If the mouse leaves the canvas, this will indicate the most recent position over the canvas, and mouseInBounds will be set to false.

mouseY

Number

Defined in mouseY:121

READ-ONLY. The current mouse Y position on the canvas. If the mouse leaves the canvas, this will indicate the most recent position over the canvas, and mouseInBounds will be set to false.

name

String

Inherited from DisplayObject: name:243

An optional name for this display object. Included in toString(). Useful for debugging.

Default: null

onClick

Function deprecated

Inherited from DisplayObject: onClick:392

Deprecated: In favour of the "click" event. Will be removed in a future version.

The onClick callback is called when the user presses down on and then releases the mouse button over this display object. The handler is passed a single param containing the corresponding MouseEvent instance. If an onClick handler is set on a container, it will receive the event if any of its children are clicked.

onDoubleClick

Function deprecated

Inherited from DisplayObject: onDoubleClick:402

Deprecated: In favour of the "dblClick" event. Will be removed in a future version.

The onDoubleClick callback is called when the user double clicks over this display object. The handler is passed a single param containing the corresponding MouseEvent instance. If an onDoubleClick handler is set on a container, it will receive the event if any of its children are clicked.

onMouseDown

Function deprecated

Defined in onMouseDown:147

Deprecated: In favour of the "stagemousedown" event. Will be removed in a future version.

The onMouseDown callback is called when the user presses the mouse button over the canvas. The handler is passed a single param containing the corresponding MouseEvent instance.

onMouseMove

Function deprecated

Defined in onMouseMove:129

Deprecated: In favour of the "stagemousemove" event. Will be removed in a future version.

The onMouseMove callback is called when the user moves the mouse over the canvas. The handler is passed a single param containing the corresponding MouseEvent instance.

onMouseOut

Function deprecated

Inherited from DisplayObject: onMouseOut:421

Deprecated: In favour of the "mouseout" event. Will be removed in a future version.

The onMouseOut callback is called when the user rolls off of the display object. You must enable this event using stage.enableMouseOver(). The handler is passed a single param containing the corresponding MouseEvent instance.

onMouseOver

Function deprecated

Inherited from DisplayObject: onMouseOver:412

Deprecated: In favour of the "mouseover" event. Will be removed in a future version.

The onMouseOver callback is called when the user rolls over the display object. You must enable this event using stage.enableMouseOver(). The handler is passed a single param containing the corresponding MouseEvent instance.

onMouseUp

Function deprecated

Defined in onMouseUp:138

Deprecated: In favour of the "stagemouseup" event. Will be removed in a future version.

The onMouseUp callback is called when the user releases the mouse button anywhere that the page can detect it. The handler is passed a single param containing the corresponding MouseEvent instance.

onPress

Function deprecated

Inherited from DisplayObject: onPress:381

Deprecated: In favour of the "mousedown" event. Will be removed in a future version.

The onPress callback is called when the user presses down on their mouse over this display object. The handler is passed a single param containing the corresponding MouseEvent instance. You can subscribe to the onMouseMove and onMouseUp callbacks of the event object to receive these events until the user releases the mouse button. If an onPress handler is set on a container, it will receive the event if any of its children are clicked.

onTick

Function deprecated

Inherited from DisplayObject: onTick:430

Deprecated: In favour of the "tick" event. Will be removed in a future version.

The onTick callback is called on each display object on a stage whenever the stage updates. This occurs immediately before the rendering (draw) pass. When stage.update() is called, first all display objects on the stage have onTick called, then all of the display objects are drawn to stage. Children will have their onTick called in order of their depth prior to onTick being called on their parent.

Any parameters passed in to stage.update() are passed on to the onTick() handlers. For example, if you call stage.update("hello"), all of the display objects with a handler will have onTick("hello") called.

parent

Container final

Inherited from DisplayObject: parent:251

A reference to the Container or Stage object that contains this display object, or null if it has not been added to one. READ-ONLY.

Default: null

regX

Number

Inherited from DisplayObject: regX:261

The x offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around it's center, you would set regX and regY to 50.

Default: 0

regY

Number

Inherited from DisplayObject: regY:270

The y offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around it's center, you would set regX and regY to 50.

Default: 0

rotation

Number

Inherited from DisplayObject: rotation:279

The rotation in degrees for this display object.

Default: 0

scaleX

Number

Inherited from DisplayObject: scaleX:287

The factor to stretch this display object horizontally. For example, setting scaleX to 2 will stretch the display object to twice it's nominal width.

Default: 1

scaleY

Number

Inherited from DisplayObject: scaleY:296

The factor to stretch this display object vertically. For example, setting scaleY to 0.5 will stretch the display object to half it's nominal height.

Default: 1

shadow

Shadow

Inherited from DisplayObject: shadow:321

A shadow object that defines the shadow to render on this display object. Set to null to remove a shadow. If null, this property is inherited from the parent container.

Default: null

skewX

Number

Inherited from DisplayObject: skewX:305

The factor to skew this display object horizontally.

Default: 0

skewY

Number

Inherited from DisplayObject: skewY:313

The factor to skew this display object vertically.

Default: 0

snapToPixel

Boolean deprecated

Inherited from DisplayObject: snapToPixel:365

Deprecated: Hardware acceleration in modern browsers makes this unnecessary.

Indicates whether the display object should have it's x & y position rounded prior to drawing it to stage. Snapping to whole pixels can result in a sharper and faster draw for images (ex. Bitmap & cached objects). This only applies if the enclosing stage has snapPixelsEnabled set to true. The snapToPixel property is true by default for Bitmap and BitmapAnimation instances, and false for all other display objects.

Note that this applies only rounds the display object's local position. You should ensure that all of the display object's ancestors (parent containers) are also on a whole pixel. You can do this by setting the ancestors' snapToPixel property to true.

Default: false

snapToPixelEnabled

Boolean deprecated

Defined in snapToPixelEnabled:156

Deprecated: Hardware acceleration makes this not beneficial

Indicates whether this stage should use the snapToPixel property of display objects when rendering them. See DisplayObject.snapToPixel for more information.

Default: false

tick

Function deprecated

Defined in tick:274

Deprecated: In favour of using Ticker.addEventListener in conjunction with handleEvent.

Calls the update method. Useful for adding stage as a listener to Ticker directly.

tickOnUpdate

Boolean

Defined in tickOnUpdate:174

If true, tick callbacks will be called on all display objects on the stage prior to rendering to the canvas. You can call

Default: true

visible

Boolean

Inherited from DisplayObject: visible:330

Indicates whether this display object should be rendered to the canvas and included when running Stage.getObjectsUnderPoint().

Default: true

x

Number

Inherited from DisplayObject: x:339

The x (horizontal) position of the display object, relative to its parent.

Default: 0

y

Number

Inherited from DisplayObject: y:347

Default: 0

Events

click

Inherited from DisplayObject: click:162

Available since 0.6.0

Dispatched when the user presses their left mouse button and then releases it while over the display object. See the MouseEvent class for a listing of event properties.

dblClick

Inherited from DisplayObject: dblClick:169

Available since 0.6.0

Dispatched when the user double clicks their left mouse button over this display object. See the MouseEvent class for a listing of event properties.

mousedown

Inherited from DisplayObject: mousedown:155

Available since 0.6.0

Dispatched when the user presses their left mouse button over the display object. See the MouseEvent class for a listing of event properties.

mouseout

Inherited from DisplayObject: mouseout:185

Available since 0.6.0

Dispatched when the user's mouse rolls out of this display object. This event must be enabled using enableMouseOver. See the MouseEvent class for a listing of event properties.

mouseover

Inherited from DisplayObject: mouseover:176

Available since 0.6.0

Dispatched when the user's mouse rolls over this display object. This event must be enabled using Stage.enableMouseOver. See the MouseEvent class for a listing of event properties.

stagemousemove

Defined in stagemousemove:74

Available since 0.6.0

Dispatched when the user moves the mouse over the canvas. See the MouseEvent class for a listing of event properties.

stagemouseup

Defined in stagemouseup:81

Available since 0.6.0

Dispatched when the user releases the mouse button anywhere that the page can detect it (this varies slightly between browsers). See the MouseEvent class for a listing of event properties.

stagemouseup

Defined in stagemouseup:88

Available since 0.6.0

Dispatched when the user the user releases the mouse button anywhere that the page can detect it (this varies slightly between browsers). See the MouseEvent class for a listing of event properties.

tick

Inherited from DisplayObject: tick:193

Available since 0.6.0

Dispatched on each display object on a stage whenever the stage updates. This occurs immediately before the rendering (draw) pass. When update is called, first all display objects on the stage dispatch the tick event, then all of the display objects are drawn to stage. Children will have their tick event dispatched in order of their depth prior to the event being dispatched on their parent.

Event Payload:

  • target Object

    The object that dispatched the event.

  • type String

    The event type.

  • params Array

    An array containing any arguments that were passed to the Stage.update() method. For example if you called stage.update("hello"), then the params would be ["hello"].