The Stage is the drawing area where all display objects are rendered to. Place a Canvas element to your HTML and use the Stage to wrap all the rendering functions to this Canvas element.
Example HTML:
<canvas id="stage"></canvas>
Example Dart:
var canvas = querySelector("#stage");
var stage = new Stage(canvas, width: 800, height: 600);
- Inheritance
Constants
- mouseLeaveEvent → EventStreamProvider<Event>
-
const EventStreamProvider<Event>
(Event.MOUSE_LEAVE) - resizeEvent → EventStreamProvider<Event>
-
const EventStreamProvider<Event>
(Event.RESIZE)
Static Properties
- defaultOptions → StageOptions
-
read / write
Constructors
- Stage(CanvasElement canvas, { int width, int height, StageOptions options })
Properties
- align → StageAlign
-
Gets and sets the alignment of this Stage inside of the Canvas element. You can choose between nine different align modes defined in
StageAlign
.read / write - alpha → num
-
write-only
- backgroundColor → int
-
Gets and sets the background color of this Stage.
read / write - blendMode → BlendMode
-
A value from the
BlendMode
class that specifies which blend mode to use.read / write, inherited - bounds → Rectangle<num>
-
read-only, inherited
- boundsTransformed → Rectangle<num>
-
Returns a rectangle that defines the area of this display object in this display object's parent coordinates.
read-only, inherited - cache → RenderTextureQuad
-
This getter gives you access to the underlying
RenderTextureQuad
if a cache is applied to this display object. If no cache is applied this value is ´null´.read-only, inherited - children → DisplayObjectChildren<DisplayObject>
-
read-only, inherited
- contentRectangle → Rectangle<num>
-
Gets the available content area on the stage. The value of this rectangle changes with the scaleMode and the alignment of the stage, as well as the size of the underlying Canvas element.
read-only - displayObjectID → int
-
read-only, inherited
- doubleClickEnabled → bool
-
Specifies whether the object receives doubleClick events.
read / write, inherited - filters → List<BitmapFilter>
-
The filters currently associated with this display object.
read / write, inherited - focus → InteractiveObject
-
The interactive object with keyboard focus or null if focus is not set.
read / write - globalTransformationMatrix → Matrix
-
The global 2D transformation matrix of this display object.
read-only, inherited - globalTransformationMatrix3D → Matrix3D
-
The global 3D transformation matrix of this display object.
read-only, inherited - hashCode → int
-
Get a hash code for this object.
read-only, inherited - height → num
-
write-only
- juggler → Juggler
-
A dedicated Juggler for this Stage. This Juggler is driven by the RenderLoop where this Stage is added to. If this Stage is not added to a RenderLoop, the Juggler will not advance in time.
read-only - mask → Mask
-
The calling display object is masked by the specified mask object.
read / write, inherited - mouseChildren → bool
-
Determines whether or not the children of the object are mouse, or user input device, enabled.
read / write, inherited - mouseCursor → String
-
Defines the mouse cursor that is displayed on this interactive object.
read / write, inherited - mouseEnabled → bool
-
Specifies whether this object receives mouse, or other user input, messages.
read / write, inherited - mousePosition → Point<num>
-
Gets the last known mouse position in Stage coordinates.
read-only - mouseX → num
-
The x-coordinate of the mouse relative to the local coordinate system of the display object.
read-only, inherited - mouseY → num
-
The y-coordinate of the mouse relative to the local coordinate system of the display object.
read-only, inherited - name → String
-
The instance name of this display object.
read / write, inherited - numChildren → int
-
The number of children of this container.
read-only, inherited - off → bool
-
The availability and visibility of the display object.
read / write, inherited - onAdded → EventStream<Event>
-
Dispatched when a display object is added to the display list.
read-only, inherited - onAddedToStage → EventStream<Event>
-
Dispatched when a display object is added to the on stage display list, either directly or through the addition of a sub tree in which the display object is contained.
read-only, inherited - onEnterFrame → EventStream<EnterFrameEvent>
-
Dispatched when a frame is entered.
read-only, inherited - onExitFrame → EventStream<ExitFrameEvent>
-
Dispatched when a frame is exited. All frame scripts have been run.
read-only, inherited - onKeyDown → EventStream<KeyboardEvent>
-
Dispatched when the user presses a key.
read-only, inherited - onKeyUp → EventStream<KeyboardEvent>
-
Dispatched when the user releases a key.
read-only, inherited - onMouseClick → EventStream<MouseEvent>
-
Dispatched when a user presses and releases the main button of the user's pointing device over the same InteractiveObject.
read-only, inherited - onMouseContextMenu → EventStream<MouseEvent>
-
Dispatched when a user gesture triggers the context menu associated with this interactive object.
read-only, inherited - onMouseDoubleClick → EventStream<MouseEvent>
-
Dispatched when a user presses and releases the main button of a pointing device twice in rapid succession over the same InteractiveObject when that object's
doubleClickEnabled
flag is set to true.read-only, inherited - onMouseDown → EventStream<MouseEvent>
-
Dispatched when a user presses the pointing device button over an InteractiveObject instance.
read-only, inherited - onMouseLeave → EventStream<Event>
-
read-only
- onMouseMiddleClick → EventStream<MouseEvent>
-
Dispatched when a user presses and releases the middle button of the user's pointing device over the same InteractiveObject.
read-only, inherited - onMouseMiddleDown → EventStream<MouseEvent>
-
Dispatched when a user presses the middle pointing device button over an InteractiveObject instance.
read-only, inherited - onMouseMiddleUp → EventStream<MouseEvent>
-
Dispatched when a user releases the pointing device button over an InteractiveObject instance.
read-only, inherited - onMouseMove → EventStream<MouseEvent>
-
Dispatched when a user moves the pointing device while it is over an InteractiveObject.
read-only, inherited - onMouseOut → EventStream<MouseEvent>
-
Dispatched when the user moves a pointing device away from an InteractiveObject instance.
read-only, inherited - onMouseOver → EventStream<MouseEvent>
-
Dispatched when the user moves a pointing device over an InteractiveObject instance.
read-only, inherited - onMouseRightClick → EventStream<MouseEvent>
-
Dispatched when a user presses and releases the right button of the user's pointing device over the same InteractiveObject.
read-only, inherited - onMouseRightDown → EventStream<MouseEvent>
-
Dispatched when a user presses the right button over an InteractiveObject instance.
read-only, inherited - onMouseRightUp → EventStream<MouseEvent>
-
Dispatched when a user releases the right button over an InteractiveObject instance.
read-only, inherited - onMouseRollOut → EventStream<MouseEvent>
-
Dispatched when the user moves a pointing device away from an InteractiveObject instance.
read-only, inherited - onMouseRollOver → EventStream<MouseEvent>
-
Dispatched when the user moves a pointing device over an InteractiveObject instance.
read-only, inherited - onMouseUp → EventStream<MouseEvent>
-
Dispatched when a user releases the pointing device button over an InteractiveObject instance.
read-only, inherited - onMouseWheel → EventStream<MouseEvent>
-
Dispatched when a mouse wheel is spun over an InteractiveObject instance.
read-only, inherited - onRemoved → EventStream<Event>
-
Dispatched when a display object is about to be removed from the display list.
read-only, inherited - onRemovedFromStage → EventStream<Event>
-
Dispatched when a display object is about to be removed from the display list, either directly or through the removal of a sub tree in which the display object is contained.
read-only, inherited - onRender → EventStream<RenderEvent>
-
Dispatched when the display list is about to be updated and rendered.
read-only, inherited - onResize → EventStream<Event>
-
read-only
- onTextInput → EventStream<TextEvent>
-
Dispatched when a user enters one or more characters of text.
read-only, inherited - onTouchBegin → EventStream<TouchEvent>
-
Dispatched when the user first contacts a touch-enabled device.
read-only, inherited - onTouchCancel → EventStream<TouchEvent>
-
Dispatched when the touch event is canceled.
read-only, inherited - onTouchEnd → EventStream<TouchEvent>
-
Dispatched when the user removes contact with a touch-enabled device.
read-only, inherited - onTouchMove → EventStream<TouchEvent>
-
Dispatched when the user touches the device, and is continuously dispatched until the point of contact is removed.
read-only, inherited - onTouchOut → EventStream<TouchEvent>
-
Dispatched when the user moves the point of contact away from InteractiveObject instance on a touch-enabled device.
read-only, inherited - onTouchOver → EventStream<TouchEvent>
-
Dispatched when the user moves the point of contact over an InteractiveObject instance on a touch-enabled device.
read-only, inherited - onTouchRollOut → EventStream<TouchEvent>
-
Dispatched when the user moves the point of contact away from an InteractiveObject instance on a touch-enabled device.
read-only, inherited - onTouchRollOver → EventStream<TouchEvent>
-
Dispatched when the user moves the point of contact over an InteractiveObject instance on a touch-enabled device.
read-only, inherited - onTouchTap → EventStream<TouchEvent>
-
Dispatched when the user lifts the point of contact over the same InteractiveObject instance on which the contact was initiated on a touch-enabled device.
read-only, inherited - parent → DisplayObjectParent
-
The
DisplayObjectContainer
object that contains this display object.read-only, inherited - pivotX → num
-
write-only
- pivotY → num
-
write-only
- pixelRatio → num
-
Gets and sets the pixel ratio of the Stage.
read / write - preventDefaultOnKeyboard → bool
-
Prevents the browser's default behavior for keyboard events.
read / write - preventDefaultOnMouse → bool
-
Prevents the browser's default behavior for mouse events.
read / write - preventDefaultOnTouch → bool
-
Prevents the browser's default behavior for touch events.
read / write - preventDefaultOnWheel → bool
-
Prevents the browser's default behavior for wheel events.
read / write - renderEngine → RenderEngine
-
Gets the underlying render engine used to draw the pixels to the screen. The returned string is defined in
RenderEngine
and is either "WebGL" or "Canvas2D".read-only - renderLoop → RenderLoop
-
Gets the
RenderLoop
where this Stage was added to, or NULL in case this Stage is not added to aRenderLoop
.read-only - renderMode → StageRenderMode
-
Gets and sets the render mode of this Stage. You can choose between three different modes defined in
StageRenderMode
.read / write - root → DisplayObject
-
The top-most display object in the portion of the display list's tree structure.
read-only, inherited - rotation → num
-
write-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited - scaleMode → StageScaleMode
-
Gets and sets the scale mode of this Stage. You can choose between four different modes defined in
StageScaleMode
.read / write - scaleX → num
-
write-only
- scaleY → num
-
write-only
- skewX → num
-
write-only
- skewY → num
-
write-only
- sourceHeight → int
-
Gets and sets the height of the Stage in world coordinates. The initial value of
sourceHeight
is the height of the canvas element or the height provided in the constructor of the Stage.read / write - sourceWidth → int
-
Gets and sets the width of the Stage in world coordinates. The initial value of
sourceWidth
is the width of the canvas element or the width provided in the constructor of the Stage.read / write - stage → Stage
-
The
Stage
of this display object.read-only, inherited - stageHeight → int
-
Gets the height of the Stage in screen coordinates/pixels.
read-only - stageWidth → int
-
Gets the width of the Stage in screen coordinates/pixels.
read-only - tabChildren → bool
-
Determines whether the children of this container are tab enabled.
read / write, inherited - tabEnabled → bool
-
Specifies whether this object is in the tab order.
read / write, inherited - tabIndex → int
-
Specifies the tab ordering of objects.
read / write, inherited - transformationMatrix → Matrix
-
The transformation matrix of this display object relative to this display object's parent.
read-only, inherited - useHandCursor → bool
-
read / write, inherited
- userData → dynamic
-
The user-defined data associated with this display object.
read / write, inherited - visible → bool
-
The visibility and availability of the display object.
read / write, inherited - width → num
-
write-only
- x → num
-
write-only
- y → num
-
write-only
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
addChild(
DisplayObject child) → void -
Adds a child DisplayObject to this DisplayObjectContainer.
inherited -
addChildAt(
DisplayObject child, int index) → void -
Adds a child DisplayObject to this DisplayObjectContainer at the specified
index
position.inherited -
addEventListener(
String eventType, EventListener eventListener, { bool useCapture: false, int priority: 0 }) → StreamSubscription<Event> -
Adds an event listener to receive events.
inherited -
addTo(
DisplayObjectParent parent) → void -
Add this display object to the specified
parent
.inherited -
alignPivot(
[HorizontalAlign hAlign = HorizontalAlign.Center, VerticalAlign vAlign = VerticalAlign.Center ]) → void -
Aligns the display object's pivot point relative to the current bounds.
inherited -
applyCache(
num x, num y, num width, num height, { bool debugBorder: false, num pixelRatio: 1.0 }) → void -
Draws the specified area of this display object to an internal render texture and the engine will use this texture to optimize performance.
inherited -
contains(
DisplayObject child) → bool -
Determines whether the specified DisplayObject is a child of this DisplayObjectContainer instance or the instance itself.
inherited -
dispatchEvent(
Event event) → void -
Dispatches the
event
to all listening subscribers.inherited -
dispatchEventRaw(
Event event, EventDispatcher target, EventPhase eventPhase) → void -
Do not use the dispatchEventRaw method unless you want to override the way how events are dispatched for display list object. Please use dispatchEvent instead.
inherited -
getBounds(
DisplayObject targetSpace) → Rectangle<num> -
Returns the bounds of this display object relative to the specified
targetSpace
.inherited -
getChildAt(
int index) → DisplayObject -
Returns the child DisplayObject at the specified
index
.inherited -
getChildByName(
String name) → DisplayObject -
Returns the child DisplayObject that exists with the specified name.
inherited -
getChildIndex(
DisplayObject child) → int -
Returns the index position of a child DisplayObject.
inherited -
getObjectsUnderPoint(
Point<num> point) → List<DisplayObject> -
Returns a list of display objects that lie under the specified point and are children (or grandchildren, and so on) of this display object container.
inherited -
getTransformationMatrix(
DisplayObject targetSpace) → Matrix -
The 2D transformation matrix relative to the given
targetSpace
.inherited -
getTransformationMatrix3D(
DisplayObject targetSpace) → Matrix3D -
The 3D transformation matrix relative to the given
targetSpace
.inherited -
globalToLocal(
Point<num> globalPoint, [ Point<num> returnPoint ]) → Point<num> -
Converts the point object from the Stage's global coordinates to this display object's local coordinates.
inherited -
hasEventListener(
String eventType, { bool useCapture: false }) → bool -
Returns true if the EventDispatcher has event listeners. The
useCapture
paramenter defines if the event listeners should be registered for the capturing event phase or not.inherited -
hitTestInput(
num localX, num localY) → DisplayObject -
Evaluates this display object to see if the coordinates
localX
andlocalY
are inside this display object. -
hitTestObject(
DisplayObject other) → bool -
Evaluates this display object to see if it overlaps or intersects with the bounding box of the
other
display object.inherited -
hitTestPoint(
num x, num y, [ bool shapeFlag = false ]) → bool -
Evaluates this display object to see if it overlaps or intersects with the point specified by the
x
andy
parameters.inherited -
invalidate(
) → void -
Calling this method will cause an RenderEvent to be fired right before the next frame will be rendered by the render loop. To receive the render event attach a listener to DisplayObject.onRender.
-
localToGlobal(
Point<num> localPoint, [ Point<num> returnPoint ]) → Point<num> -
Converts the point object from this display object's local coordinates to the Stage global coordinates.
inherited -
localToParent(
Point<num> localPoint, [ Point<num> returnPoint ]) → Point<num> -
Converts the point object from this display object's local coordinates to this display object's parent coordinates.
inherited -
materialize(
num currentTime, num deltaTime) → void -
This method is called by the RenderLoop where this Stage is added to. If this Stage is not added to a RenderLoop you could call this method on your own and therefore get full control of the rendering of this Stage.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
on<T extends Event>(
String eventType) → EventStream<T> -
Returns an event stream of type
eventType
.inherited -
parentToLocal(
Point<num> parentPoint, [ Point<num> returnPoint ]) → Point<num> -
Converts the point object from this display obejct's parent coordinates to this display object's local coordinates.
inherited -
refreshCache(
) → void -
Refreshes the cached area of this display object.
inherited -
removeCache(
) → void -
Removes the previously cached area of this display object.
inherited -
removeChild(
DisplayObject child) → void -
Removes the specified
child
from the child list of this DisplayObjectContainer.inherited -
removeChildAt(
int index) → void -
Removes the child DisplayObject from the specified
index
position in the child list of this DisplayObjectContainer.inherited -
removeChildren(
[int beginIndex, int endIndex ]) → void -
Removes all child DisplayObject instances from the child list of this DisplayObjectContainer instance.
inherited -
removeEventListener(
String eventType, EventListener eventListener, { bool useCapture: false }) → void -
Removes an event listener to stop receiving events.
inherited -
removeEventListeners(
String eventType) → void -
Removes all event listeners of a given event type.
inherited -
removeFromParent(
) → void -
Removes this display object from its parent.
inherited -
render(
RenderState renderState) → void -
Renders this display object with the given
renderState
. The display object is rendered without its filters.inherited -
renderFiltered(
RenderState renderState) → void -
Renders this display object with the given
renderState
. The display object is rendered with its filters.inherited -
replaceChildAt(
DisplayObject child, int index) → void -
Replaces the child at the specified
index
position with the newchild
. The current child at this position is removed.inherited -
setChildIndex(
DisplayObject child, int index) → void -
Changes the position of an existing
child
in this DisplayObjectContainer to the newindex
.inherited -
setTransform(
num x, num y, [ num scaleX, num scaleY, num rotation, num skewX, num skewY, num pivotX, num pivotY ]) → void -
Sets transformation properties.
inherited -
sortChildren(
int compare(DisplayObject a, DisplayObject b)) → void -
Sorts the child list according to the order specified by the
compare
Function.inherited -
swapChildren(
DisplayObject child1, DisplayObject child2) → void -
Swaps the z-order (front-to-back order) of the two specified child objects.
inherited -
swapChildrenAt(
int index1, int index2) → void -
Swaps the z-order (front-to-back order) of the child objects at the two specified index positions in the child list.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited