API Documentation for: 1.0.0
Show:

StageGL Class

Extends Stage
Defined in: StageGL:56
Module: EaselJS

A StageGL instance is the root level Container for an WebGL-optimized display list, which is used in place of the usual Stage. This class should behave identically to a Stage except for WebGL-specific functionality.

Each time the tick method is called, the display list is rendered to the target <canvas/> instance, ignoring non-WebGL-compatible display objects. On devices and browsers that don't support WebGL, content will automatically be rendered to canvas 2D context instead.

Limitations

  • Shape, Shadow, and Text are not rendered when added to the display list.
  • To display something StageGL cannot render, cache the object. Caches can be rendered regardless of source.
  • Images are wrapped as a webGL "Texture". Each graphics card has a limit to its concurrent Textures, too many Textures will noticeably slow performance.
  • Each cache counts as an individual Texture. As such SpriteSheet and SpriteSheetBuilder are recommended practices to help keep texture counts low.
  • To use any image node (DOM Image/Canvas Element) between multiple StageGL instances it must be a clone, otherwise the GPU texture loading and tracking will get confused.
  • to avoid an up/down scaled render you must call updateViewport if you resize your canvas after making a StageGL instance, this will properly size the WebGL context stored in memory.
  • Best performance in demanding scenarios will come from manual management of texture memory, but it is handled automatically by default. See releaseTexture for details.

Example

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

 var stage = new createjs.StageGL("canvasElementId");

 var image = new createjs.Bitmap("imagePath.png");
 stage.addChild(image);

 createjs.Ticker.on("tick", handleTick);

 function handleTick(event) {
     image.x += 10;
     stage.update();
 }

Notes

  • StageGL is not currently included in the minified version of EaselJS.
  • SpriteContainer (the previous approach to WebGL with EaselJS) has been deprecated.
  • Earlier versions of WebGL support in EaselJS (SpriteStage and SpriteContainer) had hard limitations on images per container, which have been solved.

Constructor

StageGL

(
  • canvas
  • options
)

Defined in StageGL:56

Parameters:

  • canvas HTMLCanvasElement | String | Object

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

  • options Object

    All the option parameters in a reference object, some are not supported by some browsers.

    • [preserveBuffer=false] Boolean optional

      If true, the canvas is NOT auto-cleared by WebGL (the spec discourages setting this to true). This is useful if you want persistent draw effects.

    • [antialias=false] Boolean optional

      Specifies whether or not the browser's WebGL implementation should try to perform anti-aliasing. This will also enable linear pixel sampling on power-of-two textures (smoother images).

    • [transparent=false] Boolean optional

      If true, the canvas is transparent. This is very expensive, and should be used with caution.

    • [premultiply=false] Boolean optional

      Alters color handling. If true, this assumes the shader must account for pre-multiplied alpha. This can help avoid visual halo effects with some assets, but may also cause problems with other assets.

    • [autoPurge=1200] Integer optional

      How often the system should automatically dump unused textures with purgeTextures(autoPurge) every autoPurge/2 draws. See purgeTextures for more information.

Item Index

Methods

Properties

Methods

_appendToBatchGroup

(
  • container
  • gl
  • concatMtx
  • concatAlpha
  • ignoreCache
)
protected

Add all the contents of a container to the pending buffers, called recursively on each container. This may trigger a draw if a buffer runs out of space. This is the main workforce of the render loop.

Parameters:

  • container Container

    The Container that contains everything to be drawn.

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • concatMtx Matrix2D

    The effective (concatenated) transformation matrix when beginning this container

  • concatAlpha Number

    The effective (concatenated) alpha when beginning this container

  • ignoreCache Boolean

    Don't use an element's cache during this draw

_applyShadow

(
  • ctx
  • shadow
)
protected

Parameters:

  • ctx CanvasRenderingContext2D
  • shadow Shadow

_backupBatchTextures

(
  • restore
  • [target=this._backupTextures]
)
protected

Store or restore current batch textures into a backup array

Parameters:

  • restore Boolean

    Perform a restore instead of a store.

  • [target=this._backupTextures] Array optional

    Where to perform the backup, defaults to internal backup.

_batchDraw

(
  • gl
  • sceneGraph
  • ignoreCache
)
protected

Defined in _batchDraw:1969

Begin the drawing process for a regular render.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • sceneGraph Stage | | Container

    Container object with all that needs to rendered, preferably a Stage.

  • ignoreCache Boolean

_cacheDraw

(
  • target
  • filters
  • manager
)
protected

Defined in _cacheDraw:1994

Perform the drawing process to fill a specific cache texture, including applying filters.

Parameters:

  • target DisplayObject

    The object we're drawing into the cache. For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).

  • filters Array

    The filters we're drawing into cache.

  • manager BitmapCache

    The BitmapCache instance looking after the cache

_cloneProps

(
  • o
)
DisplayObject protected

Parameters:

  • o DisplayObject

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

Returns:

_createBuffers

(
  • gl
)
protected

Defined in _createBuffers:1633

Sets up the necessary vertex property buffers, including position and U/V.

Parameters:

  • gl WebGLRenderingContext

_createShader

(
  • gl
  • type
  • str
)
WebGLShader protected

Defined in _createShader:1598

Creates a shader from the specified string replacing templates. Template items are defined via {{ key }}`.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • type Number

    The type of shader to create. gl.VERTEX_SHADER | gl.FRAGMENT_SHADER

  • str String

    The definition for the shader.

Returns:

WebGLShader:

_dispatchEvent

(
  • eventObj
  • eventPhase
)
protected

Parameters:

_dispatchMouseEvent

(
  • target
  • type
  • bubbles
  • pointerId
  • o
  • [nativeEvent]
  • [relatedTarget]
)
protected

Inherited from Stage: _dispatchMouseEvent:838

Parameters:

_drawBuffers

(
  • gl
)
protected

Defined in _drawBuffers:2340

Draws all the currently defined cards in the buffer to the render surface.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

_drawBuffers

(
  • gl
  • flipY
)
protected

Defined in _drawBuffers:2389

Draws a card that covers the entire render surface. Mainly used for filters.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • flipY Boolean

    Covers are used for things like RenderTextures and because of 3D vs Canvas space this can end up meaning the y space sometimes requires flipping in the render.

_drawFilters

(
  • target
  • filters
  • manager
)

Defined in _drawFilters:2066

Sub portion of _cacheDraw, split off for readability. Do not call independently.

Parameters:

  • target DisplayObject

    The object we're drawing with a filter.

  • filters Array

    The filters we're drawing into cache.

  • manager BitmapCache

    The BitmapCache instance looking after the cache

_fetchShaderProgram

(
  • gl
  • [shaderName="regular"]
  • [customVTX]
  • [customFRAG]
  • [shaderParamSetup]
)
WebGLProgram protected

Create the completed Shader Program from the vertex and fragment shaders. Allows building of custom shaders for filters. Once compiled, shaders are saved so. If the Shader code requires dynamic alterations re-run this function to generate a new shader.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • [shaderName="regular"] String optional

    Working values: "regular", "override", and "filter". Which type of shader to build. Filter and override both accept the custom params. Regular and override have all features. Filter is a special case reduced feature shader meant to be over-ridden.

  • [customVTX] String optional

    Extra vertex shader information to replace a regular draw, see StageGL/COVER_VERTEX_BODY for default and Filter for examples.

  • [customFRAG] String optional

    Extra fragment shader information to replace a regular draw, see StageGL/COVER_FRAGMENT_BODY for default and Filter for examples.

  • [shaderParamSetup] Function optional

    Function to run so custom shader parameters can get applied for the render.

Returns:

WebGLProgram:

The compiled and linked shader

_fetchWebGLContext

(
  • canvas
  • options
)
WebGLRenderingContext protected

Sets up and returns the WebGL context for the canvas. May return undefined in error scenarios. These can include situations where the canvas element already has a context, 2D or GL.

Parameters:

  • canvas Canvas

    The DOM canvas element to attach to

  • options Object

    The options to be handed into the WebGL object, see WebGL spec

Returns:

WebGLRenderingContext:

The WebGL context, may return undefined in error scenarios

_getBounds

(
  • matrix
  • ignoreTransform
)
Rectangle protected

Inherited from DisplayObject but overwritten in _getBounds:681

Parameters:

  • matrix Matrix2D
  • ignoreTransform Boolean

    If true, does not apply this object's transform.

Returns:

_getElementRect

(
  • e
)
protected

Inherited from Stage: _getElementRect:571

Parameters:

_getNumChildren

() Number protected

Inherited from Container: _getNumChildren:97

Use the numChildren property instead.

Returns:

_getObjectsUnderPoint

(
  • x
  • y
  • arr
  • mouse
  • activeListener
  • currentDepth
)
DisplayObject protected

Parameters:

  • x Number
  • y Number
  • arr Array
  • mouse Boolean

    If true, it will respect mouse interaction properties like mouseEnabled, mouseChildren, and active listeners.

  • activeListener Boolean

    If true, there is an active mouse event listener on a parent object.

  • currentDepth Number

    Indicates the current depth of the search.

Returns:

_getPointerData

(
  • id
)
protected

Inherited from Stage: _getPointerData:599

Parameters:

_getStage

() Stage protected

Inherited from DisplayObject: _getStage:672

Use the stage property instead.

Returns:

_handleDoubleClick

(
  • e
  • owner
)
protected

Inherited from Stage: _handleDoubleClick:823

Parameters:

  • e MouseEvent
  • owner Stage

    Indicates that the event has already been captured & handled by the indicated stage.

_handleMouseDown

(
  • e
)
protected

Inherited from Stage: _handleMouseDown:722

Parameters:

_handleMouseMove

(
  • e
)
protected

Inherited from Stage: _handleMouseMove:610

Parameters:

_handleMouseUp

(
  • e
)
protected

Inherited from Stage: _handleMouseUp:685

Parameters:

_handlePointerDown

(
  • id
  • e
  • pageX
  • pageY
  • owner
)
protected

Inherited from Stage: _handlePointerDown:731

Parameters:

  • id Number
  • e Event
  • pageX Number
  • pageY Number
  • owner Stage

    Indicates that the event has already been captured & handled by the indicated stage.

_handlePointerMove

(
  • id
  • e
  • pageX
  • pageY
  • owner
)
protected

Inherited from Stage: _handlePointerMove:620

Parameters:

  • id Number
  • e Event
  • pageX Number
  • pageY Number
  • owner Stage

    Indicates that the event has already been captured & handled by the indicated stage.

_handlePointerUp

(
  • id
  • e
  • clear
  • owner
)
protected

Inherited from Stage: _handlePointerUp:694

Parameters:

  • id Number
  • e Event
  • clear Boolean
  • owner Stage

    Indicates that the event has already been captured & handled by the indicated stage.

_initializeWebGL

() WebGLRenderingContext protected

Create and properly initialize the WebGL instance.

Returns:

WebGLRenderingContext:

_initTextures

() protected

Defined in _initTextures:1711

Do all the setup steps for textures in the system.

_insertTextureInBatch

(
  • gl
  • texture
)
protected

Adds the texture to a spot in the current batch, forcing a draw if no spots are free.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • texture WebGLTexture

    The texture to be inserted.

_isMouseOpaque

() Boolean protected

Indicates whether the display object has any mouse event listeners or a cursor.

Returns:

_killTextureObject

(
  • tex
)
protected

Remove and clean the texture, expects a texture and is inflexible. Mostly for internal use, recommended to call releaseTexture instead as it will call this with the correct texture object(s). Note: Testing shows this may not happen immediately, have to wait frames for WebGL to have actually adjust memory.

Parameters:

  • tex Texture

    The texture to be cleaned out

_loadTextureImage

(
  • gl
  • image
)
WebGLTexture protected

Load a specific texture, accounting for potential delay, as it might not be preloaded.

Parameters:

  • gl WebGLRenderingContext
  • image Image

    Actual image to be loaded

Returns:

WebGLTexture:

The resulting Texture object

_testHit

(
  • ctx
)
Boolean protected

Inherited from DisplayObject: _testHit:1291

Parameters:

  • ctx CanvasRenderingContext2D

Returns:

_testMask

(
  • target
  • x
  • y
)
Boolean protected

Inherited from Container: _testMask:650

Parameters:

Returns:

Boolean:

Indicates whether the x/y is within the masked region.

_testMouseOver

(
  • clear
  • owner
  • eventTarget
)
protected

Inherited from Stage: _testMouseOver:754

Parameters:

  • clear Boolean

    If true, clears the mouseover / rollover (ie. no target)

  • owner Stage

    Indicates that the event has already been captured & handled by the indicated stage.

  • eventTarget Stage

    The stage that the cursor is actively over.

_tick

(
  • evtObj
)
protected

Inherited from DisplayObject but overwritten in _tick:547

Parameters:

  • evtObj Object

    An event object that will be dispatched to all tick listeners. This object is reused between dispatchers to reduce construction & GC costs.

_transformBounds

(
  • bounds
  • matrix
  • ignoreTransform
)
Rectangle protected

Parameters:

Returns:

_updatePointerPosition

(
  • id
  • e
  • pageX
  • pageY
)
protected

Parameters:

_updateState

()

Called before the object gets drawn and is a chance to ensure the display state of the object is correct. Mostly used by MovieClip and BitmapText to correct their internal state and children prior to being drawn.

Is manually called via draw in a Stage but is automatically called when present in a StageGL instance.

addChild

(
  • child
)
DisplayObject

Inherited from Container: addChild:173

Adds a child to the top of the display list.

Example

    container.addChild(bitmapInstance);

You can also add multiple children at once:

    container.addChild(bitmapInstance, shapeInstance, textInstance);

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:204

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.

Example

 addChildAt(child1, index);

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. Fails silently if the index is out of range.

Parameters:

Returns:

DisplayObject:

Returns the last child that was added, or the last child if multiple children were added.

addEventListener

(
  • type
  • listener
  • [useCapture]
)
Function | Object

Adds the specified event listener. Note that adding multiple listeners to the same function will result in multiple callbacks getting fired.

Example

 displayObject.addEventListener("click", handleClick);
 function handleClick(event) {
    // Click happened.
 }

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.

  • [useCapture] Boolean optional

    For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.

Returns:

Function | Object:

Returns the listener for chaining or assignment.

buildUVRects

(
  • spritesheet
  • [target=-1]
  • [onlyTarget=false]
)
Object static

Defined in buildUVRects:461

Calculate the U/V co-ordinate based info for sprite frames. Instead of pixel count it uses a 0-1 space. Also includes the ability to get info back for a specific frame, or only calculate that one frame.

//generate UV rects for all entries
StageGL.buildUVRects( spriteSheetA );
//generate all, fetch the first
var firstFrame = StageGL.buildUVRects( spriteSheetB, 0 );
//generate the rect for just a single frame for performance's sake
var newFrame = StageGL.buildUVRects( dynamicSpriteSheet, newFrameIndex, true );

NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • spritesheet SpriteSheet

    The spritesheet to find the frames on

  • [target=-1] Int optional

    The index of the frame to return

  • [onlyTarget=false] Boolean optional

    Whether "target" is the only frame that gets calculated

Returns:

Object:

the target frame if supplied and present or a generic frame {t, l, b, r}

cache

(
  • x
  • y
  • width
  • height
  • [scale=1]
  • [options=undefined]
)

Inherited from DisplayObject: cache:792

Draws the display object into a new element, which is then used for subsequent draws. Intended 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 its content changes, you must manually update the cache by calling updateCache() again. You must specify the cached 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.

Example

For example if you defined a Shape that drew a circle at 0, 0 with a radius of 25:

 var shape = new createjs.Shape();
 shape.graphics.beginFill("#ff0000").drawCircle(0, 0, 25);
 shape.cache(-25, -25, 50, 50);

Note that filters need to be defined before the cache is applied or you will have to call updateCache after application. Check out the Filter class for more information. Some filters (ex. BlurFilter) may not work as expected in conjunction with the scale param.

Usually, the resulting cacheCanvas will have the dimensions width scale, height scale, however some filters (ex. BlurFilter) will add padding to the canvas dimensions.

In previous versions caching was handled on DisplayObject but has since been moved to BitmapCache. This allows for easier interaction and alternate cache methods like WebGL with StageGL. For more information on the options object, see the BitmapCache BitmapCache/define.

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=1] 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.

  • [options=undefined] Object optional

    Specify additional parameters for the cache logic

cacheDraw

(
  • target
  • filters
  • manager
)
Boolean

Defined in cacheDraw:1006

Draws the target into the correct context, be it a canvas or Render Texture using WebGL.

NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • target DisplayObject

    The object we're drawing into cache. For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself).

  • filters Array

    The filters we're drawing into cache.

  • manager BitmapCache

    The BitmapCache instance looking after the cache

Returns:

Boolean:

If the draw was handled by this function

clear

()

Inherited from Stage: clear:438

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

clone

()

Inherited from DisplayObject but overwritten in clone:552

Stage instances cannot be cloned.

cloneChildren

(
  • o
)
protected

Inherited from Container: cloneChildren:562

Recursively clones all children of this container, and adds them to the target container.

Parameters:

contains

(
  • child
)
Boolean

Inherited from Container: contains:430

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
  • [bubbles]
  • [cancelable]
)
Boolean

Dispatches the specified event to all listeners.

Example

 // Use a string event
 this.dispatchEvent("complete");

 // Use an Event instance
 var event = new createjs.Event("progress");
 this.dispatchEvent(event);

Parameters:

  • eventObj Object | String | Event

    An object with a "type" property, or a string type. While a generic object will work, it is recommended to use a CreateJS Event instance. If a string is used, dispatchEvent will construct an Event instance if necessary with the specified type. This latter approach can be used to avoid event object instantiation for non-bubbling events that may not have any listeners.

  • [bubbles] Boolean optional

    Specifies the bubbles value when a string was passed to eventObj.

  • [cancelable] Boolean optional

    Specifies the cancelable value when a string was passed to eventObj.

Returns:

Boolean:

Returns false if preventDefault() was called on a cancelable event, true otherwise.

draw

(
  • context
  • [ignoreCache=false]
)
Boolean

Inherited from DisplayObject but overwritten in draw:984

Draws the stage into the supplied context if possible. Many WebGL properties only exist on their context. As such you cannot share contexts among many StageGLs and each context requires a unique StageGL instance. Contexts that don't match the context managed by this StageGL will be treated as a 2D context.

NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • context CanvasRenderingContext2D | WebGLRenderingContext

    The context object to draw into.

  • [ignoreCache=false] Boolean optional

    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).

Returns:

Boolean:

If the draw was handled by this function

enableDOMEvents

(
  • [enable=true]
)

Inherited from Stage: enableDOMEvents:512

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.

When changing the canvas property you must disable the events on the old canvas, and enable events on the new canvas or mouse events will not work as expected. For example:

 myStage.enableDOMEvents(false);
 myStage.canvas = anotherCanvas;
 myStage.enableDOMEvents(true);

Parameters:

  • [enable=true] Boolean optional

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

enableMouseOver

(
  • [frequency=20]
)

Inherited from Stage: enableMouseOver:481

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

Example

 var stage = new createjs.Stage("canvasId");
 stage.enableMouseOver(10); // 10 updates per second

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.

getBaseTexture

(
  • [w=1]
  • [h=1]
)

Defined in getBaseTexture:1286

Returns a base texture that has no image or data loaded. Not intended for loading images. It may return null in some error cases, and trying to use a "null" texture can cause renders to fail.

Parameters:

  • [w=1] Uint optional

    The width of the texture in pixels, defaults to 1

  • [h=1] Uint optional

    The height of the texture in pixels, defaults to 1

getBounds

() Rectangle

Inherited from DisplayObject: getBounds:1089

Returns a rectangle representing this object's bounds in its local coordinate system (ie. with no transformation). Objects that have been cached will return the bounds of the cache.

Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use setBounds so that they are included when calculating Container bounds.

All All display objects support setting bounds manually using setBounds(). Likewise, display objects that have been cached using cache() will return the bounds of their cache. Manual and cache bounds will override the automatic calculations listed below.
Bitmap Returns the width and height of the sourceRect (if specified) or image, extending from (x=0,y=0).
Sprite Returns the bounds of the current frame. May have non-zero x/y if a frame registration point was specified in the spritesheet data. See also getFrameBounds
Container Returns the aggregate (combined) bounds of all children that return a non-null value from getBounds().
Shape Does not currently support automatic bounds calculations. Use setBounds() to manually define bounds.
Text Returns approximate bounds. Horizontal values (x/width) are quite accurate, but vertical values (y/height) are not, especially when using textBaseline values other than "top".
BitmapText Returns approximate bounds. Values will be more accurate if spritesheet frame registration points are close to (x=0,y=0).

Bounds can be expensive to calculate for some objects (ex. text, or containers with many children), and are recalculated each time you call getBounds(). You can prevent recalculation on static objects by setting the bounds explicitly:

var bounds = obj.getBounds();
obj.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
// getBounds will now use the set values, instead of recalculating

To reduce memory impact, the returned Rectangle instance may be reused internally; clone the instance or copy its values if you need to retain it.

var myBounds = obj.getBounds().clone();
// OR:
myRect.copy(obj.getBounds());

Returns:

Rectangle:

A Rectangle instance representing the bounds, or null if bounds are not available for this object.

getCacheDataURL

() String

Returns a data URL for the cache, or null if this display object is not cached. Only generated if the cache has changed, otherwise returns last result.

Returns:

String:

The image data url for the cache.

getChildAt

(
  • index
)
DisplayObject

Inherited from Container: getChildAt:314

Returns the child at the specified index.

Example

 container.getChildAt(2);

Parameters:

  • index Number

    The index of the child to return.

Returns:

DisplayObject:

The child at the specified index. Returns null if there is no child at the index.

getChildByName

(
  • name
)
DisplayObject

Inherited from Container: getChildByName:329

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:363

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

Example

 var index = container.getChildIndex(child);

Parameters:

Returns:

Number:

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

getConcatenatedDisplayProps

(
  • [props]
)
DisplayProps

Generates a DisplayProps object representing the combined display properties of the object and all of its parent Containers up to the highest level ancestor (usually the Stage).

Parameters:

  • [props] DisplayProps optional

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

Returns:

DisplayProps:

The combined display properties.

getConcatenatedMatrix

(
  • [matrix]
)
Matrix2D

Generates a 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:

  • [matrix] Matrix2D optional

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

Returns:

Matrix2D:

The combined matrix.

getFilterShader

(
  • filter
)
WebGLProgram

Fetches the shader compiled and set up to work with the provided filter/object. The shader is compiled on first use and returned on subsequent calls.

Parameters:

  • filter Filter | Object

    The object which will provide the information needed to construct the filter shader.

Returns:

WebGLProgram:

getMatrix

(
  • matrix
)
Matrix2D

Inherited from DisplayObject: getMatrix:991

Returns a matrix based on this object's current 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.

getObjectsUnderPoint

(
  • x
  • y
  • [mode=0]
)
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 DisplayObject/mousemove:event), and only if the mouse's position has changed.

  • By default (mode=0) this method evaluates all display objects.
  • By setting the mode parameter to 1, the mouseEnabled and MouseChildren:property properties will be respected.
  • Setting the mode to 2 additionally excludes display objects that do not have active mouse event listeners or a DisplayObject:cursor:property property. That is, only objects that would normally intercept mouse interaction will be included. This can significantly improve performance in some cases by reducing the number of display objects that need to be tested.
  • This method accounts for both hitArea and mask.

Parameters:

  • x Number

    The x position in the container to test.

  • y Number

    The y position in the container to test.

  • [mode=0] Number optional

    The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.

Returns:

Array:

An Array of DisplayObjects under the specified coordinates.

getObjectUnderPoint

(
  • x
  • y
  • mode
)
DisplayObject

Similar to getObjectsUnderPoint, but returns only the top-most display object. This runs significantly faster than getObjectsUnderPoint(), but is still potentially 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.

  • mode Number

    The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.

Returns:

DisplayObject:

The top-most display object under the specified coordinates.

getRenderBufferTexture

(
  • w
  • h
)
Texture

Returns a base texture (see getBaseTexture) for details. Also includes an attached and linked render buffer in texture._frameBuffer. RenderTextures can be thought of as an internal canvas on the GPU that can be drawn to.

Parameters:

  • w Number

    The width of the texture in pixels.

  • h Number

    The height of the texture in pixels.

Returns:

Texture:

the basic texture instance with a render buffer property.

getTargetRenderTexture

(
  • target
  • w
  • h
)
Objet

Render textures can't draw into themselves so any item being used for renderTextures needs two to alternate between. This function creates, gets, and toggles the render surface between the two.

NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • target DisplayObject

    The object associated with the render textures, usually a cached object.

  • w Number

    The width to create the texture at.

  • h Number

    The height to create the texture at.

Returns:

Objet:

getTransformedBounds

() Rectangle

Returns a rectangle representing this object's bounds in its parent's coordinate system (ie. with transformations applied). Objects that have been cached will return the transformed bounds of the cache.

Not all display objects can calculate their own bounds (ex. Shape). For these objects, you can use setBounds so that they are included when calculating Container bounds.

To reduce memory impact, the returned Rectangle instance may be reused internally; clone the instance or copy its values if you need to retain it.

Container instances calculate aggregate bounds for all children that return bounds via getBounds.

Returns:

Rectangle:

A Rectangle instance representing the bounds, or null if bounds are not available for this object.

globalToLocal

(
  • x
  • y
  • [pt]
)
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.

Example

 displayObject.x = 300;
 displayObject.y = 200;
 stage.addChild(displayObject);
 var point = displayObject.globalToLocal(100, 100);
 // Results in x=-200, y=-100

Parameters:

  • x Number

    The x position on the stage to transform.

  • y Number

    The y position on the stage to transform.

  • [pt] Point | Object optional

    An object to copy the result into. If omitted a new Point object with x/y properties will be returned.

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:445

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

() deprecated

Inherited from Container: initialize:123

Deprecated: in favour of `createjs.promote()`

Constructor alias for backwards compatibility. This method will be removed in future versions. Subclasses should be updated to use Utility Methods/extends.

isVisible

() Boolean

Inherited from DisplayObject but overwritten in isVisible:131

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

isWebGLActive

(
  • ctx
)
Boolean static

Defined in isWebGLActive:503

Test a context to see if it has WebGL enabled on it.

Parameters:

  • ctx CanvasContext

    The context to test

Returns:

Boolean:

Whether WebGL is enabled

localToGlobal

(
  • x
  • y
  • [pt]
)
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.

Example

 displayObject.x = 300;
 displayObject.y = 200;
 stage.addChild(displayObject);
 var point = displayObject.localToGlobal(100, 100);
 // Results in x=400, y=300

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.

  • [pt] Point | Object optional

    An object to copy the result into. If omitted a new Point object with x/y properties will be returned.

Returns:

Point:

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

localToLocal

(
  • x
  • y
  • target
  • [pt]
)
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 using the following code with localToGlobal and globalToLocal.

 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 source display object to transform.

  • target DisplayObject

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

  • [pt] Point | Object optional

    An object to copy the result into. If omitted a new Point object with x/y properties will be returned.

Returns:

Point:

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

off

(
  • type
  • listener
  • [useCapture]
)

Inherited from EventDispatcher: off:249

A shortcut to the removeEventListener method, with the same parameters and return value. This is a companion to the .on method.

IMPORTANT: To remove a listener added with on, you must pass in the returned wrapper function as the listener. See on for an example.

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    The listener function or object.

  • [useCapture] Boolean optional

    For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.

on

(
  • type
  • listener
  • [scope]
  • [once=false]
  • [data]
  • [useCapture=false]
)
Function

Inherited from EventDispatcher: on:173

A shortcut method for using addEventListener that makes it easier to specify an execution scope, have a listener only run once, associate arbitrary data with the listener, and remove the listener.

This method works by creating an anonymous wrapper function and subscribing it with addEventListener. The wrapper function is returned for use with removeEventListener (or off).

IMPORTANT: To remove a listener added with on, you must pass in the returned wrapper function as the listener, or use remove. Likewise, each time you call on a NEW wrapper function is subscribed, so multiple calls to on with the same params will create multiple listeners.

Example

    var listener = myBtn.on("click", handleClick, null, false, {count:3});
    function handleClick(evt, data) {
        data.count -= 1;
        console.log(this == myBtn); // true - scope defaults to the dispatcher
        if (data.count == 0) {
            alert("clicked 3 times!");
            myBtn.off("click", listener);
            // alternately: evt.remove();
        }
    }

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.

  • [scope] Object optional

    The scope to execute the listener in. Defaults to the dispatcher/currentTarget for function listeners, and to the listener itself for object listeners (ie. using handleEvent).

  • [once=false] Boolean optional

    If true, the listener will remove itself after the first time it is triggered.

  • [data] optional

    Arbitrary data that will be included as the second parameter when the listener is called.

  • [useCapture=false] Boolean optional

    For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.

Returns:

Function:

Returns the anonymous function that was created and assigned as the listener. This is needed to remove the listener later using .removeEventListener.

protectTextureSlot

(
  • id
  • [lock=false]
)

Blocks, or frees a texture "slot" on the GPU. Can be useful if you are overflowing textures. When overflowing textures they are re-uploaded to the GPU every time they're encountered, this can be expensive with large textures. By blocking the slot you reduce available slots, potentially increasing draw calls, but mostly you prevent a texture being re-uploaded if it would have moved slots due to overflow.

NOTE: This method is mainly for internal use, though it may be useful for advanced uses. For example, block the slot a background image is stored in so there is less re-loading of that image.

Parameters:

  • id Number

    The slot to be affected

  • [lock=false] Boolean optional

    Whether this slot is the one being locked.

purgeTextures

(
  • [count=100]
)

Defined in purgeTextures:1156

Similar to ReleaseTexture, but this function differs by searching for textures to release. It works by assuming that it can purge any texture which was last used more than "count" draw calls ago. Because this process is unaware of the objects and whether they may be used on your stage, false positives can occur. It is recommended to manually manage your memory with releaseTexture, however, there are many use cases where this is simpler and error-free. This process is also run by default under the hood to prevent leaks. To disable it see the autoPurge property.

Parameters:

  • [count=100] Number optional

    How many renders ago the texture was last used

releaseTexture

(
  • item
)

Defined in releaseTexture:1090

For every image encountered StageGL registers and tracks it automatically. This tracking can cause memory leaks if not purged. StageGL, by default, automatically purges them. This does have a cost and may unfortunately find false positives. This function is for manual management of this memory instead of the automatic system controlled by the autoPurge property.

This function will recursively remove all textures found on the object, its children, cache, etc. It will uncache objects and remove any texture it finds REGARDLESS of whether it is currently in use elsewhere. It is up to the developer to ensure that a texture in use is not removed.

Textures in use, or to be used again shortly, should not be removed. This is simply for performance reasons. Removing a texture in use will cause the texture to have to be re-uploaded slowing rendering.

Parameters:

  • item DisplayObject | Texture | Image | Canvas

    An object that used the texture to be discarded.

removeAllChildren

()

Removes all children from the display list.

Example

container.removeAllChildren();

removeAllEventListeners

(
  • [type]
)

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

Example

 // Remove all listeners
 displayObject.removeAllEventListeners();

 // Remove all click listeners
 displayObject.removeAllEventListeners("click");

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:244

Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is already known.

Example

 container.removeChild(child);

You can also remove multiple children:

 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.

removeChildAt

(
  • index
)
Boolean

Inherited from Container but overwritten in removeChildAt:271

Removes the child at the specified index from the display list, and sets its parent to null.

Example

 container.removeChildAt(2);

You can also remove multiple children:

 container.removeChild(2, 7, ...)

Returns true if the child (or children) was removed, or false if any index was out of range.

Parameters:

  • index Number

    The index of the child to remove.

Returns:

Boolean:

true if the child (or children) was removed, or false if any index was out of range.

removeEventListener

(
  • type
  • listener
  • [useCapture]
)

Removes the specified event listener.

Important Note: that you must pass the exact function reference used when the event was added. If a proxy function, or function closure is used as the callback, the proxy/closure reference must be used - a new proxy or closure will not work.

Example

 displayObject.removeEventListener("click", handleClick);

Parameters:

  • type String

    The string type of the event.

  • listener Function | Object

    The listener function or object.

  • [useCapture] Boolean optional

    For events that bubble, indicates whether to listen for the event in the capture or bubbling/target phase.

resizeTexture

(
  • texture
  • [width=1]
  • [height=1]
)
protected

Defined in resizeTexture:1305

Resizes a supplied texture element. May generate invalid textures in some error cases such as; when the texture is too large, when an out of texture memory error occurs, or other error scenarios. Trying to use an invalid texture can cause renders to hard stop on some devices. Check the WebGL bound texture after running this function.

NOTE: The supplied texture must have been made with the WebGL "texImage2D" function, all default APIs in StageGL use this, so this note only matters for library developers and plugins.

Parameters:

  • texture WebGLTexture

    The GL Texture to be modified.

  • [width=1] Uint optional

    The width of the texture in pixels, defaults to 1

  • [height=1] Uint optional

    The height of the texture in pixels, defaults to 1

set

(
  • props
)
DisplayObject chainable

Inherited from DisplayObject: set:1071

Provides a chainable shortcut method for setting a number of properties on the instance.

Example

 var myGraphics = new createjs.Graphics().beginFill("#ff0000").drawCircle(0, 0, 25);
 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 instance the method is called on (useful for chaining calls.)

setBounds

(
  • x
  • y
  • width
  • height
)

Inherited from DisplayObject: setBounds:1174

Allows you to manually specify the bounds of an object that either cannot calculate their own bounds (ex. Shape & Text) for future reference, or so the object can be included in Container bounds. Manually set bounds will always override calculated bounds.

The bounds should be specified in the object's local (untransformed) coordinates. For example, a Shape instance with a 25px radius circle centered at 0,0 would have bounds of (-25, -25, 50, 50).

Parameters:

  • x Number

    The x origin of the bounds. Pass null to remove the manual bounds.

  • y Number

    The y origin of the bounds.

  • width Number

    The width of the bounds.

  • height Number

    The height of the bounds.

setChildIndex

(
  • child
  • index
)

Inherited from Container: setChildIndex:413

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:

setClearColor

(
  • [color=0x00000000]
)

Defined in setClearColor:1392

Changes the webGL clear, aka "background" color to the provided value. A transparent clear is recommended, as non-transparent colours may create undesired boxes around some visuals.

The clear color will also be used for filters and other "render textures". The stage background will ignore the transparency value and display a solid color normally. For the stage to recognize and use transparency it must be created with the transparent flag set to true (see StageGL/constructor)).

Using "transparent white" to demonstrate, the valid data formats are as follows:

  • "#FFF"
  • "#FFFFFF"
  • "#FFFFFF00"
  • "rgba(255,255,255,0.0)"

Parameters:

  • [color=0x00000000] String | Int optional

    The new color to use as the background

setTextureParams

(
  • gl
  • [isPOT=false]
)

Common utility function used to apply the correct texture processing parameters for the bound texture.

Parameters:

  • gl WebGLRenderingContext

    The canvas WebGL context object to draw into.

  • [isPOT=false] Boolean optional

    Marks whether the texture is "Power of Two", this may allow better quality AA.

setTransform

(
  • [x=0]
  • [y=0]
  • [scaleX=1]
  • [scaleY=1]
  • [rotation=0]
  • [skewX=0]
  • [skewY=0]
  • [regX=0]
  • [regY=0]
)
DisplayObject chainable

Shortcut method to quickly set the transform properties on the display object. All parameters are optional. Omitted parameters will have the default value set.

Example

 displayObject.setTransform(100, 100, 2, 2);

Parameters:

  • [x=0] Number optional

    The horizontal translation (x position) in pixels

  • [y=0] Number optional

    The vertical translation (y position) in pixels

  • [scaleX=1] Number optional

    The horizontal scale, as a percentage of 1

  • [scaleY=1] Number optional

    the vertical scale, as a percentage of 1

  • [rotation=0] Number optional

    The rotation, in degrees

  • [skewX=0] Number optional

    The horizontal skew factor

  • [skewY=0] Number optional

    The vertical skew factor

  • [regX=0] Number optional

    The horizontal registration point in pixels

  • [regY=0] Number optional

    The vertical registration point in pixels

Returns:

DisplayObject:

Returns this instance. Useful for chaining commands.

sortChildren

(
  • sortFunction
)

Inherited from Container: sortChildren:343

Performs an array sort operation on the child list.

Example: Display children with a higher y in front.

 var sortFunction = function(obj1, obj2, options) {
     if (obj1.y > obj2.y) { return 1; }
     if (obj1.y < obj2.y) { return -1; }
     return 0;
 }
 container.sortChildren(sortFunction);

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:393

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:378

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

Parameters:

tick

(
  • [props]
)

Inherited from Stage: tick:380

Propagates a tick event through the display list. This is automatically called by update unless tickOnUpdate is set to false.

If a props object is passed to tick(), then all of its properties will be copied to the event object that is propagated to listeners.

Some time-based features in EaselJS (for example Sprite/framerate require that a tick event object (or equivalent object with a delta property) be passed as the props parameter to tick(). For example:

Ticker.on("tick", handleTick);
function handleTick(evtObj) {
    // clone the event object from Ticker, and add some custom data to it:
    var evt = evtObj.clone().set({greeting:"hello", name:"world"});

    // pass it to stage.update():
    myStage.update(evt); // subsequently calls tick() with the same param
}

// ...
myDisplayObject.on("tick", handleDisplayObjectTick);
function handleDisplayObjectTick(evt) {
    console.log(evt.delta); // the delta property from the Ticker tick event object
    console.log(evt.greeting, evt.name); // custom data: "hello world"
}

Parameters:

  • [props] Object optional

    An object with properties that should be copied to the event object. Should usually be a Ticker event object, or similar object with a delta property.

toDataURL

(
  • [backgroundColor]
  • [mimeType="image/png"]
)
String

Inherited from Stage: toDataURL:449

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 optional

    The background color to be used for the generated image. Any valid CSS color value is allowed. The default value is a transparent background.

  • [mimeType="image/png"] String optional

    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:560

Returns a string representation of this object.

Returns:

String:

a string representation of the instance.

uncache

()

Inherited from DisplayObject: uncache:864

Clears the current cache. See cache for more information.

update

(
  • [props]
)

Inherited from Stage: update:349

Each time the update method is called, the stage will call tick unless tickOnUpdate is set to false, and then render the display list to the canvas.

Parameters:

  • [props] Object optional

    Props object to pass to tick(). Should usually be a Ticker event object, or similar object with a delta property.

updateCache

(
  • compositeOperation
)

Inherited from DisplayObject: updateCache:835

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.

Example

Clear the current graphics of a cached shape, draw some new instructions, and then update the cache. The new line will be drawn on top of the old one.

 // Not shown: Creating the shape, and caching it.
 shapeInstance.clear();
 shapeInstance.setStrokeStyle(3).beginStroke("#ff0000").moveTo(100, 100).lineTo(200,200);
 shapeInstance.updateCache();

In previous versions caching was handled on DisplayObject but has since been moved to BitmapCache. This allows for easier interaction and alternate cache methods like WebGL and StageGL.

Parameters:

updateContext

(
  • 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.

updateSimultaneousTextureCount

(
  • [count=1]
)

Try to set the max textures the system can handle. It should default to the hardware maximum, and lower values may limit performance. Some devices have been known to mis-report their max textures, or you may need a standard baseline cross devices for testing. Barring the previous suggestions, there is little need to call this function as the library will automatically try to find the best value.

NOTE: This method is mainly for internal use, though it may be useful for advanced uses.

Parameters:

  • [count=1] Number optional

    The number of textures intended for simultaneous loading.

updateViewport

(
  • width
  • height
)

Defined in updateViewport:1217

Update the WebGL viewport. Note that this does not update the canvas element's width/height, but the render surface's instead. This is necessary after manually resizing the canvas element on the DOM to avoid a up/down scaled render.

Parameters:

  • width Integer

    The width of the render surface in pixels.

  • height Integer

    The height of the render surface in pixels.

willTrigger

(
  • type
)
Boolean

Indicates whether there is at least one listener for the specified event type on this object or any of its ancestors (parent, parent's parent, etc). A return value of true indicates that if a bubbling event of the specified type is dispatched from this object, it will trigger at least one listener.

This is similar to hasEventListener, but it searches the entire event flow for a listener, not just this object.

Parameters:

  • type String

    The string type of the event.

Returns:

Boolean:

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

Properties

_activeShader

WebGLProgram protected

Defined in _activeShader:249

The shader program used to draw the current batch.

Default: null

_alphaBuffer

WebGLBuffer protected

Defined in _alphaBuffer:321

The WebGL buffer attached to _alphas.

Default: null

_alphas

Float32Array protected

Defined in _alphas:312

The vertices data for the current draw call.

Default: null

_antialias

Boolean protected

Defined in _antialias:156

Specifies whether or not the browser's WebGL implementation should try to perform anti-aliasing.

Default: false

_autoPurge

Integer protected

Defined in _autoPurge:183

Internal value of StageGL/autoPurge

Default: null

_baseTextures

Array protected

Defined in _baseTextures:355

An array of all the simple filler textures used to prevent issues with missing textures in a batch.

_batchId

Number protected

Defined in _batchId:388

The current batch being drawn, A batch consists of a call to drawElements on the GPU. Many of these calls can occur per draw.

Default: 0

_batchTextureCount

Number protected

The number of concurrent textures the GPU can handle. This value is dynamically set from WebGL during initialization via gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS). The WebGL spec states that the lowest guaranteed value is 8, but it could be higher. Do not set this value higher than the value returned by the GPU. Setting it lower will probably reduce performance, but may be advisable to reserve slots for custom filter work. NOTE: Can also act as a length for {{#crossLink "StageGL/_batchTextures:property"}}.

Default: 8

_batchTextures

Array protected

Defined in _batchTextures:347

An array of all the textures currently loaded into the GPU. The index in the array matches the GPU index.

_bounds

Rectangle protected

Inherited from DisplayObject: _bounds:443

Default: null

_cacheContainer

Container protected

Defined in _cacheContainer:445

Used to counter-position the object being cached so it aligns with the cache surface. Additionally ensures that all rendering starts with a top level container.

Default: An instance of an EaselJS Container.

_cacheDataURL

String deprecated protected

Moved to BitmapCache

Default: null

_cacheDataURLID

Number deprecated protected

Moved to BitmapCache

Default: 0

_cacheScale

Number deprecated protected

Inherited from DisplayObject: _cacheScale:400

Moved to BitmapCache

Default: 1

_captureListeners

Object protected

_clearColor

Object protected

Defined in _clearColor:230

The color to use when the WebGL canvas has been cleared. May appear as a background color. Defaults to grey.

Default: {r: 0.50, g: 0.50, b: 0.50, a: 0.00}

_drawID

Number protected

Defined in _drawID:398

The current draw being performed, may contain multiple batches. Comparing to StageGL/_batchID:property can reveal batching efficiency.

Default: 0

_drawTexture

Array protected

Defined in _drawTexture:330

An index based lookup of every WebGL Texture currently in use.

_indices

Float32Array protected

Defined in _indices:294

The vertex indices data for the current draw call.

Default: null

_isDrawing

Number protected

Defined in _isDrawing:416

Used to prevent nested draw calls from accidentally overwriting drawing information by tracking depth.

Default: 0

_lastTextureInsert

Number protected

The location at which the last texture was inserted into a GPU slot in _batchTextures. Manual control of this variable can yield improvements in performance by intelligently replacing textures inside a batch to reduce texture re-load. It is impossible to write automated general use code, as it requires display list look ahead inspection and/or render foreknowledge.

Default: -1

_lastTrackedCanvas

Number protected

Used to ensure every canvas used as a texture source has a unique ID.

Default: 0

_listeners

Object protected

Inherited from EventDispatcher: _listeners:99

_maxCardsPerBatch

Number protected

The maximum number of cards (aka a single sprite) that can be drawn in one draw call. Use getter/setters to modify otherwise internal buffers may be incorrect sizes.

Default: StageGL.DEFAULT_MAX_BATCH_SIZE (10000)

_mouseOverIntervalID

Number protected

_nextStage

Stage protected

Inherited from Stage: _nextStage:214

_pointerCount

Object private

Inherited from Stage: _pointerCount:191

Number of active pointers.

_pointerData

Object private

Inherited from Stage: _pointerData:182

Holds objects with data for each active pointer id. Each object has the following properties: x, y, event, target, overTarget, overX, overY, inBounds, posEvtObj (native event that last updated position)

_premultiply

Boolean protected

Defined in _premultiply:174

Specifies whether or not StageGL is handling colours as premultiplied alpha.

Default: false

_preserveBuffer

Boolean protected

Defined in _preserveBuffer:145

Specifies whether or not the canvas is auto-cleared by WebGL. The WebGL spec discourages true. If true, the canvas is NOT auto-cleared by WebGL. Used when the canvas context is created and requires context re-creation to update.

Default: false

_prevStage

Stage protected

Inherited from Stage: _prevStage:221

_primaryPointerID

Object private

Inherited from Stage: _primaryPointerID:199

The ID of the primary pointer.

_projectionMatrix

Float32Array protected

A 2D projection matrix used to convert WebGL's viewspace into canvas co-ordinates. Regular canvas display uses Top-Left values of [0,0] where WebGL uses a Center [0,0] Top-Right [1,1] (euclidean) system.

Default: null

_props

DisplayObject protected

Inherited from DisplayObject: _props:427

Default: null

_rectangle

Rectangle protected

Inherited from DisplayObject: _rectangle:435

Default: null

_slotBlackList

Array protected

Defined in _slotBlackList:408

Used to prevent textures in certain GPU slots from being replaced by an insert.

_textureIDs

Object protected

Defined in _textureIDs:338

A string based lookup hash of which index a texture is stored at in the dictionary. The lookup string is often the src url.

_textureIndexBuffer

WebGLBuffer protected

The WebGL buffer attached to _indices.

Default: null

_transparent

Boolean protected

Defined in _transparent:165

Specifies whether or not the browser's WebGL implementation should be transparent.

Default: false

_uvPositionBuffer

WebGLBuffer protected

The WebGL buffer attached to _uvs.

Default: null

_uvs

Float32Array protected

Defined in _uvs:276

The vertex U/V data for the current draw call.

Default: null

_vertexPositionBuffer

WebGLBuffer protected

The WebGL buffer attached to _vertices.

Default: null

_vertices

Float32Array protected

Defined in _vertices:258

The vertex position data for the current draw call.

Default: null

_viewportHeight

Number protected

Defined in _viewportHeight:202

The height in px of the drawing surface saved in memory.

Default: 0

_viewportWidth

Number protected

Defined in _viewportWidth:193

The width in px of the drawing surface saved in memory.

Default: 0

_webGLContext

WebGLRenderingContext protected

Defined in _webGLContext:221

The current WebGL canvas context. Often shorthanded to just "gl" in many parts of the code.

Default: null

_webGLRenderStyle

Number protected

Where StageGL should look for required display properties, matters only for leaf display objects. Containers or cached objects won't use this property, it's for native display of terminal elements.

Default: 0

alpha

Number

Inherited from DisplayObject: alpha:144

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

Default: 1

autoClear

Boolean

Inherited from Stage: autoClear:69

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).

Example

 var stage = new createjs.Stage("canvasId");
 stage.autoClear = false;

Default: true

autoPurge

Integer protected

Defined in autoPurge:879

Specifies whether or not StageGL is automatically purging unused textures. Higher numbers purge less often. Values below 10 are upgraded to 10, and -1 disables this feature.

Default: 1000

bitmapCache

BitmapCache readonly

Inherited from DisplayObject: bitmapCache:162

If a cache has been made, this returns the class that is managing the cacheCanvas and its properties. See BitmapCache for more information. Use this to control, inspect, and change the cache. In special circumstances this may be a modified or subclassed BitmapCache.

Default: null

cacheCanvas

HTMLCanvasElement | Object readonly

Inherited from DisplayObject: cacheCanvas:152

If a cache is active, this returns the canvas that holds the image of this display object. See cache for more information. Use this to display the result of a cache. This will be a HTMLCanvasElement unless special cache rules have been deliberately enabled for this cache.

Default: null

cacheID

Number deprecated

Inherited from DisplayObject: cacheID:695

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. Moved to BitmapCache

Default: 0

canvas

HTMLCanvasElement | Object

Inherited from Stage: canvas:85

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).

When changing the canvas property you must disable the events on the old canvas, and enable events on the new canvas or mouse events will not work as expected. For example:

 myStage.enableDOMEvents(false);
 myStage.canvas = anotherCanvas;
 myStage.enableDOMEvents(true);

children

Array

Inherited from Container: children:62

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 uses.

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. For a list of supported compositeOperation value, visit the W3C draft on Compositing and Blending.

Default: null

COVER_FRAGMENT_BODY

String final static readonly

Body of the fragment shader. The cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are replaced pre-compile.

COVER_FRAGMENT_HEADER

String final static readonly

Actual full header for the fragment shader. Includes the varying header. The cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are replaced pre-compile.

COVER_UV

Float32Array final static readonly

Defined in COVER_UV:592

U/V for COVER_VERT.

COVER_UV_FLIP

Float32Array final static readonly

Defined in COVER_UV_FLIP:609

Flipped U/V for StageGL:COVER_VERT:property.

COVER_VARYING_HEADER

String final static readonly

Portion of the shader that contains the "varying" properties required in both vertex and fragment shaders. The cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are replaced pre-compile.

COVER_VERT

Float32Array final static readonly

Defined in COVER_VERT:575

Vertex positions for a card that covers the entire render. Used with render targets primarily.

COVER_VERTEX_BODY

String final static readonly

Body of the vertex shader. The cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are replaced pre-compile.

COVER_VERTEX_HEADER

String final static readonly

Actual full header for the vertex shader. Includes the varying header. The cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are replaced pre-compile.

cursor

String

Inherited from DisplayObject: cursor:388

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 enableMouseOver method to use this property. Setting a non-null cursor on a Container will override the cursor set on its descendants.

Default: null

DEFAULT_MAX_BATCH_SIZE

Number final static readonly

The default value for the maximum number of cards we want to process in a batch. See WEBGL_MAX_INDEX_NUM for a hard limit.

Default: 10000

drawRect

Rectangle

Inherited from Stage: drawRect:119

Specifies the area of the stage to affect when calling update. This can be use to selectively re-draw specific regions of the canvas. If null, the whole canvas area is drawn.

filters

Array

Inherited from DisplayObject: filters:352

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

Inherited from Stage: handleEvent:422

Default event handler that calls the Stage update method 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:173

The hitArea property is not supported for Stage.

Default: null

id

Number

Inherited from DisplayObject: id:172

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

Default: -1

INDICIES_PER_CARD

Number final static readonly

The number of triangle indices it takes to form a Card. 3 per triangle, 2 triangles.

Default: 6

isCacheControlled

Boolean protected

Controls whether final rendering output of a CacheDraw is the canvas or a render texture. See the Cache function modifications for full implications and discussion.

Default: false

isWebGL

Boolean readonly

Defined in isWebGL:870

Indicates whether WebGL is being used for rendering. For example, this would be false if WebGL is not supported in the browser.

mask

Shape

Inherited from DisplayObject: mask:362

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

mouseChildren

Boolean

Inherited from Container: mouseChildren:73

Indicates whether the children of this container are independently enabled for mouse/pointer interaction. If false, the children will be aggregated under the container - for example, a click on a child shape would trigger a click event on the container.

Default: true

mouseEnabled

Boolean

Indicates whether to include this object when running mouse interactions. Setting this to false for children of a Container will cause events on the Container to not fire when that child is clicked. Setting this property to false does not prevent the getObjectsUnderPoint method from returning the child.

Note: In EaselJS 0.7.0, the mouseEnabled property will not work properly with nested Containers. Please check out the latest NEXT version in GitHub for an updated version with this issue resolved. The fix will be provided in the next release of EaselJS.

Default: true

mouseInBounds

Boolean

Inherited from Stage: mouseInBounds:137

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

Default: false

mouseMoveOutside

Boolean

Inherited from Stage: mouseMoveOutside:153

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 readonly

Inherited from Stage: mouseX:101

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 readonly

Inherited from Stage: mouseY:110

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:205

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

Default: null

nextStage

Stage

Inherited from Stage: nextStage:302

Specifies a target stage that will have mouse / touch interactions relayed to it after this stage handles them. This can be useful in cases where you have multiple layered canvases and want user interactions events to pass through. For example, this would relay mouse events from topStage to bottomStage:

 topStage.nextStage = bottomStage;

To disable relaying, set nextStage to null.

MouseOver, MouseOut, RollOver, and RollOut interactions are also passed through using the mouse over settings of the top-most stage, but are only processed if the target stage has mouse over interactions enabled. Considerations when using roll over in relay targets:

  1. The top-most (first) stage must have mouse over interactions enabled (via enableMouseOver)
  2. All stages that wish to participate in mouse over interaction must enable them via enableMouseOver
  3. All relay targets will share the frequency value of the top-most stage
To illustrate, in this example the targetStage would process mouse over interactions at 10hz (despite passing 30 as it's desired frequency): topStage.nextStage = targetStage; topStage.enableMouseOver(10); targetStage.enableMouseOver(30);

If the target stage's canvas is completely covered by this stage's canvas, you may also want to disable its DOM events using:

targetStage.enableDOMEvents(false);

numChildren

Number readonly

Inherited from Container: numChildren:109

Returns the number of children in the container.

parent

Container final readonly

Inherited from DisplayObject: parent:214

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

Default: null

PARTICLE_FRAGMENT_BODY

String final static readonly

PARTICLE_VERTEX_BODY

String final static readonly

preventSelection

Boolean

Inherited from Stage: preventSelection:164

Prevents selection of other elements in the html page if the user clicks and drags, or double clicks on the canvas. This works by calling preventDefault() on any mousedown events (or touch equivalent) originating on the canvas.

Default: true

REGULAR_FRAGMENT_BODY

String final static readonly

Body of the fragment shader. The regular shader is designed to render all expected objects. Shader code may contain templates that are replaced pre-compile.

REGULAR_FRAGMENT_HEADER

String final static readonly

Actual full header for the fragment shader. Includes the varying header. The regular shader is designed to render all expected objects. Shader code may contain templates that are replaced pre-compile.

REGULAR_VARYING_HEADER

String final static readonly

Portion of the shader that contains the "varying" properties required in both vertex and fragment shaders. The regular shader is designed to render all expected objects. Shader code may contain templates that are replaced pre-compile.

REGULAR_VERTEX_BODY

String final static readonly

Body of the vertex shader. The regular shader is designed to render all expected objects. Shader code may contain templates that are replaced pre-compile.

REGULAR_VERTEX_HEADER

String final static readonly

Actual full header for the vertex shader. Includes the varying header. The regular shader is designed to render all expected objects. Shader code may contain templates that are replaced pre-compile.

regX

Number

Inherited from DisplayObject: regX:226

The left offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around its center, you would set regX and regY to 50. Cached object's registration points should be set based on pre-cache conditions, not cached size.

Default: 0

regY

Number

Inherited from DisplayObject: regY:236

The y offset for this display object's registration point. For example, to make a 100x100px Bitmap rotate around its center, you would set regX and regY to 50. Cached object's registration points should be set based on pre-cache conditions, not cached size.

Default: 0

rotation

Number

Inherited from DisplayObject: rotation:246

The rotation in degrees for this display object.

Default: 0

scale

Number

Inherited from DisplayObject: scale:705

Set both the scaleX and the DisplayObject/scaleY property to the same value. Note that when you get the value, if the scaleX and scaleY are different values, it will return only the scaleX.

Default: 1

scaleX

Number

Inherited from DisplayObject: scaleX:254

The factor to stretch this display object horizontally. For example, setting scaleX to 2 will stretch the display object to twice its nominal width. To horizontally flip an object, set the scale to a negative number.

Default: 1

scaleY

Number

Inherited from DisplayObject: scaleY:263

The factor to stretch this display object vertically. For example, setting scaleY to 0.5 will stretch the display object to half its nominal height. To vertically flip an object, set the scale to a negative number.

Default: 1

shadow

Shadow

Inherited from DisplayObject: shadow:288

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:272

The factor to skew this display object horizontally.

Default: 0

skewY

Number

Inherited from DisplayObject: skewY:280

The factor to skew this display object vertically.

Default: 0

snapToPixel

Boolean

Inherited from DisplayObject: snapToPixel:342

Indicates whether the display object should be drawn to a whole pixel when Stage/snapToPixelEnabled is true. To enable/disable snapping on whole categories of display objects, set this value on the prototype (Ex. Text.prototype.snapToPixel = true).

Default: true

snapToPixelEnabled

Boolean

Inherited from Stage: snapToPixelEnabled:127

Indicates whether display objects should be rendered on whole pixels. You can set the DisplayObject/snapToPixel property of display objects to false to enable/disable this behaviour on a per instance basis.

Default: false

stage

Stage readonly

Inherited from DisplayObject: stage:688

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

tickChildren

Boolean

Inherited from Container: tickChildren:83

If false, the tick will not be propagated to children of this Container. This can provide some performance benefits. In addition to preventing the "tick" event from being dispatched, it will also prevent tick related updates on some display objects (ex. Sprite & MovieClip frame advancing, DOMElement visibility handling).

Default: true

tickEnabled

Boolean

Inherited from DisplayObject: tickEnabled:195

If false, the tick will not run on this display object (or its children). This can provide some performance benefits. In addition to preventing the "tick" event from being dispatched, it will also prevent tick related updates on some display objects (ex. Sprite & MovieClip frame advancing, and DOMElement display properties).

Default: true

tickOnUpdate

Boolean

Inherited from Stage: tickOnUpdate:145

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

Default: true

transformMatrix

Matrix2D

If set, defines the transformation for this display object, overriding all other transformation properties (x, y, rotation, scale, skew).

Default: null

UV_RECT

Object final static readonly

Defined in UV_RECT:563

Default U/V rect for dealing with full coverage from an image source.

Default: {t:0, l:0, b:1, r:1}

VERTEX_PROPERTY_COUNT

Number final static readonly

The number of properties defined per vertex (x, y, textureU, textureV, textureIndex, alpha)

Default: 6

visible

Boolean

Inherited from DisplayObject: visible:297

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

Default: true

vocalDebug

Boolean

Defined in vocalDebug:135

Console log potential issues and problems. This is designed to have minimal performance impact, so if extensive debugging information is required, this may be inadequate. See WebGLInspector

Default: false

WEBGL_MAX_INDEX_NUM

Number final static readonly

The maximum size WebGL allows for element index numbers. Uses a 16 bit unsigned integer. It takes 6 indices to make a unique card.

Default: 65536

x

Number

Inherited from DisplayObject: x:306

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

Default: 0

y

Number

Inherited from DisplayObject: y:314

Default: 0

Events

added

Inherited from DisplayObject: added:646

Dispatched when the display object is added to a parent container.

click

Inherited from DisplayObject: click:546

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:553

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.

drawend

Inherited from Stage but overwritten in drawend:847

Dispatched each update immediately after the display list is drawn to the canvas and the canvas context is restored.

drawstart

Inherited from Stage but overwritten in drawstart:841

Dispatched each update immediately before the canvas is cleared and the display list is drawn to it. You can call preventDefault on the event to cancel the draw.

mousedown

Inherited from DisplayObject: mousedown:539

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.

mouseenter

Inherited from Stage: mouseenter:265

Available since 0.7.0

Dispatched when the mouse moves into the canvas area (mouseInBounds == false) from outside it (mouseInBounds == true). This is currently only dispatched for mouse input (not touch). See the MouseEvent class for a listing of event properties.

mouseleave

Inherited from Stage: mouseleave:257

Available since 0.7.0

Dispatched when the mouse moves from within the canvas area (mouseInBounds == true) to outside it (mouseInBounds == false). This is currently only dispatched for mouse input (not touch). See the MouseEvent class for a listing of event properties.

mouseout

Inherited from DisplayObject: mouseout:568

Available since 0.6.0

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

mouseover

Inherited from DisplayObject: mouseover:560

Available since 0.6.0

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

pressmove

Inherited from DisplayObject: pressmove:616

Available since 0.7.0

After a mousedown occurs on a display object, a pressmove event will be generated on that object whenever the mouse moves until the mouse press is released. This can be useful for dragging and similar operations.

Please note that if the initial mouse target from a mousedown event is removed from the stage after being pressed (e.g. during a pressmove event), a pressmove event is still generated. However since it is no longer in the display list, the event can not bubble. This means that previous ancestors (parent containers) will not receive the event, and therefore can not re-dispatch it. If you intend to listen for pressup or pressmove on a dynamic object (such as a MovieClip or Container), then ensure you set mouseChildren to false.

pressup

Inherited from DisplayObject: pressup:631

Available since 0.7.0

After a mousedown occurs on a display object, a pressup event will be generated on that object when that mouse press is released. This can be useful for dragging and similar operations.

Please note that if the initial mouse target from a mousedown event is removed from the stage after being pressed (e.g. during a pressmove event), a pressup event is still generated. However since it is no longer in the display list, the event can not bubble. This means that previous ancestors (parent containers) will not receive the event, and therefore can not re-dispatch it. If you intend to listen for pressmove or pressup on a dynamic object (such as a MovieClip or Container), then ensure you set mouseChildren to false.

removed

Inherited from DisplayObject: removed:651

Dispatched when the display object is removed from its parent container.

rollout

Inherited from DisplayObject: rollout:596

Available since 0.7.0

This event is similar to mouseout, with the following differences: it does not bubble, and it considers Container instances as an aggregate of their content.

For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over shapeA, then directly on to shapeB, then off both. With a listener for Mouseout:event on myContainer, two events would be received, each targeting a child element:

  1. when the mouse leaves shapeA (target=shapeA)
  2. when the mouse leaves shapeB (target=shapeB)
However, with a listener for "rollout" instead, only a single event is received when the mouse leaves the aggregate myContainer content (target=myContainer).

This event must be enabled using enableMouseOver. See the MouseEvent class for a listing of event properties.

rollover

Inherited from DisplayObject: rollover:576

Available since 0.7.0

This event is similar to mouseover, with the following differences: it does not bubble, and it considers Container instances as an aggregate of their content.

For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over shapeA and then directly on to shapeB. With a listener for Mouseover:event on myContainer, two events would be received, each targeting a child element:

  1. when the mouse enters shapeA (target=shapeA)
  2. when the mouse enters shapeB (target=shapeB)
However, with a listener for "rollover" instead, only a single event is received when the mouse first enters the aggregate myContainer content (target=myContainer).

This event must be enabled using enableMouseOver. See the MouseEvent class for a listing of event properties.

stagemousedown

Inherited from Stage: stagemousedown:242

Available since 0.6.0

Dispatched when the user presses their left mouse button on the canvas. See the MouseEvent class for a listing of event properties.

stagemousemove

Inherited from Stage: stagemousemove:235

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

Inherited from Stage: stagemouseup:249

Available since 0.6.0

Dispatched when the user the user presses somewhere on the stage, then releases the mouse button anywhere that the page can detect it (this varies slightly between browsers). You can use mouseInBounds to check whether the mouse is currently within the stage bounds. See the MouseEvent class for a listing of event properties.

tick

Inherited from DisplayObject: tick:656

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 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"].

tickend

Inherited from Stage: tickend:280

Available since 0.7.0

Dispatched each update immediately after the tick event is propagated through the display list. Does not fire if tickOnUpdate is false. Precedes the "drawstart" event.

tickstart

Inherited from Stage: tickstart:273

Available since 0.7.0

Dispatched each update immediately before the tick event is propagated through the display list. You can call preventDefault on the event object to cancel propagating the tick event.