EaselJS

EaselJS  0.3.2

EaselJS > EaselJS > Stage
Search:
 
Filters

Class Stage - extends Container

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

Constructor

Stage ( canvas )
Parameters:
canvas <HTMLCanvasElement> The canvas the stage will render to.

Properties

_activeMouseEvent - protected MouseEvent


_activeMouseTarget - protected DisplayObject


_mouseOverIntervalID - protected Number


_mouseOverTarget - protected DisplayObject


_mouseOverX - protected Number


_mouseOverY - protected Number


_snapToPixelEnabled - protected Boolean

Default Value: false

_tmpCanvas - protected HTMLCanvasElement


autoClear - Boolean

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

canvas - HTMLCanvasElement

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

mouseInBounds - Boolean

Indicates whether the mouse is currently within the bounds of the canvas.
Default Value: false

mouseX - final Number

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

mouseY - final Number

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

snapToPixelEnabled - Boolean

Indicates whether this stage should use the snapToPixel property of display objects when rendering them.
Default Value: false

Methods

_handleMouseDown

protected void _handleMouseDown ( e )
Parameters:
e <MouseEvent>
Returns: void

_handleMouseMove

protected void _handleMouseMove ( e )
Parameters:
e <MouseEvent>
Returns: void

_handleMouseUp

protected void _handleMouseUp ( e )
Parameters:
e <MouseEvent>
Returns: void

_testMouseOver

protected void _testMouseOver ( )
Returns: void

_updateMousePosition

protected void _updateMousePosition ( pageX , pageY )
Parameters:
pageX <Number>
pageY <Number>
Returns: void

clear

void clear ( )
Clears the target canvas. Useful if autoClear is set to false.
Returns: void

clone

Stage clone ( )
Returns a clone of this Stage.
Returns: Stage
A clone of the current Container instance.

enableMouseOver

void enableMouseOver ( frequency )
Enables or disables (by passing a frequency of 0) mouse over handlers (onMouseOver and onMouseOut) for this stage's display list. These events can be expensive to generate, so they are disabled by default, and the frequency of the events can be controlled independently of mouse move events via the frequency parameter.
Parameters:
frequency <Number> 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.
Returns: void

initialize param {HTMLCanvasElement} canvas

protected void initialize param {HTMLCanvasElement} canvas ( )
Initialization method.
Returns: void

toDataURL

String toDataURL ( backgroundColor , mimeType )
Returns a data url that contains a Base64 encoded image of the contents of the stage. The returned data url can be specified as the src value of an image element.
Parameters:
backgroundColor <String> The background color to be used for the generated image. The value can be any value HTML color value, including HEX colors, rgb and rgba. The default value is a transparent background.
mimeType <String> The MIME type of the image format to be create. The default is "image/png". If an unknown MIME type is passed in, or if the browser does not support the specified MIME type, the default value will be used.
Returns: String
a Base64 encoded image.

toString

String toString ( )
Returns a string representation of this object.
Returns: String
a string representation of the instance.

update

void update ( )
Each time the update method is called, the stage will tick any descendants exposing a tick method (ex. BitmapSequence) and render its entire display list to the canvas.
Returns: void

Events

onMouseDown

onMouseDown ( event )
The onMouseDown callback is called when the user presses the mouse button over the canvas. The handler is passed a single param containing the corresponding MouseEvent instance.
Parameters:
event <MouseEvent> A MouseEvent instance with information about the current mouse event.

onMouseMove

onMouseMove ( event )
The onMouseMove callback is called when the user moves the mouse over the canvas. The handler is passed a single param containing the corresponding MouseEvent instance.
Parameters:
event <MouseEvent> A MouseEvent instance with information about the current mouse event.

onMouseUp

onMouseUp ( event )
The onMouseUp callback is called when the user releases the mouse button anywhere that the page can detect it. The handler is passed a single param containing the corresponding MouseEvent instance.
Parameters:
event <MouseEvent> A MouseEvent instance with information about the current mouse event.

tick Broadcast to children when the stage is updated.

tick Broadcast to children when the stage is updated. ( )

Events inherited from DisplayObject: