doodle.createLayer

Description:

Layer (id:string, element:HTMLCanvasElement) :Layer

Inherits

  1. ElementNode
  2. Node
  3. Emitter
  4. Object

Parameters

  1. id:string – [optional]
  2. element:HTMLCanvasElement – [optional]

Returns

  • Layer –

Throws

  • SyntaxError –

Properties

width :number

Canvas dimensions need to apply to HTML attributes.

Returns

  • number –

Throws

  • TypeError –
filters :Array

Collection of filters to apply to the canvas bitmap.

Returns

  • Array –
alpha :number

Returns

  • number –

Throws

  • TypeError –
backgroundColor :Color

Returns

  • Color –
backgroundImage :HTMLImageElement

Returns

  • HTMLImageElement –

Throws

  • TypeError –
backgroundRepeat :string

Returns

  • string –

Throws

  • TypeError –
  • SyntaxError –
children :Array

Returns

  • Array –
clearBitmap :boolean

Returns

  • boolean –

Throws

  • TypeError –
context :CanvasRenderingContext2D

Returns

  • CanvasRenderingContext2D –
debug.boundingBox :boolean

Returns

  • boolean –
element :HTMLElement

Returns

  • HTMLElement –
height :number

Returns

  • number –

Throws

  • TypeError –
id :string

Returns

  • string –

Throws

  • TypeError –
parent :Node

Returns

  • Node –
root :Display

Returns

  • Display –
rotation :number

Returns

  • number –
transform :Matrix

Returns

  • Matrix –
visible :boolean

Returns

  • boolean –

Throws

  • TypeError –
x :number

Returns

  • number –
y :number

Returns

  • number –

Methods

on (type:string, listener:Function) :void

Adds an event listener on an Emitter object. This is convenience alias for Emitter.addListener(type, listener, useCapture=false).

Parameters

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
once (type:string, listener:Function) :void

Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

Parameters

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
appendTo () :Node

Adds this node to the given node's children.

Returns

  • Node –

Throws

  • TypeError –
setChildIndex (child:Node, index:number) :void

Changes the position of an existing child in the node's children array. This affects the layering of child objects.

Parameters

  1. child:Node –
  2. index:number –

Throws

  • TypeError –
willTrigger (type:string) :boolean

Checks whether an event listener is registered with this Emitter object or any of its ancestors for the specified event type. The difference between the hasListener() and the willTrigger() methods is that hasListener() examines only the object to which it belongs, whereas the willTrigger() method examines the entire event flow for the event specified by the type parameter.

Parameters

  1. type:string – The type of event.

Returns

  • boolean –

Throws

  • TypeError –
hasListener (type:string) :boolean

Checks whether the Emitter object has any listeners registered for a specific type of event.

Parameters

  1. type:string –

Returns

  • boolean –

Throws

  • TypeError –
contains (node:Node) :boolean

Determine if node is among it's children, grandchildren, etc.

Parameters

  1. node:Node –

Returns

  • boolean –

Throws

  • TypeError –
emit (event:doodle.events.Event) :boolean

Dispatches an event into the event flow. The event target is the Emitter object upon which the emit() method is called.

Parameters

  1. event:doodle.events.Event –

Returns

  • boolean – true if the event was successfully dispatched.

Throws

  • TypeError –
broadcast (event:doodle.events.Event) :boolean

Dispatches an event to every object with an active listener. Ignores propagation path, objects come from

Parameters

  1. event:doodle.events.Event –

Returns

  • boolean – True if the event was successfully dispatched.

Throws

  • TypeError –
  • Error –
handleEvent (event:doodle.events.Event) :boolean

Lookup and call listener if registered for specific event type.

Parameters

  1. event:doodle.events.Event –

Returns

  • boolean – true if node has listeners of event type.

Throws

  • TypeError –
addChildAt (node:Node, index:number) :Node

Parameters

  1. node:Node –
  2. index:number –

Returns

  • Node –

Throws

  • TypeError –
addChild (node:Node) :Node

Parameters

  1. node:Node –

Returns

  • Node –

Throws

  • TypeError –
createNode () :void

createSprite () :void

getChildById (id:string) :Node|undefined

Parameters

  1. id:string –

Returns

  • Node|undefined –

Throws

  • TypeError –
globalToLocal (pt:Point) :Point

Parameters

  1. pt:Point –

Returns

  • Point –

Throws

  • TypeError –
localToGlobal (pt:Point) :Point

Parameters

  1. pt:Point –

Returns

  • Point –

Throws

  • TypeError –
removeAllChildren () :void

Throws

  • TypeError –
removeChildAt (index:number) :Node

Parameters

  1. index:number –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
  • RangeError –
removeChildById (id:string) :Node

Parameters

  1. id:string –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
removeChild (node:Node) :Node

Parameters

  1. node:Node –

Returns

  • Node – Removed child node.

Throws

  • TypeError –
  • ReferenceError –
rotate (deg:number) :number

Parameters

  1. deg:number –

Returns

  • number –
scaleX (sx:number) :number

Parameters

  1. sx:number –

Returns

  • number –
scaleY (sy:number) :number

Parameters

  1. sy:number –

Returns

  • number –
swapChildren (node1:Node, node2:Node) :void

Parameters

  1. node1:Node –
  2. node2:Node –

Throws

  • TypeError –
addListener (type:string, listener:Function) :void

Registers an event listener object with an Emitter object so that the listener receives notification of an event.

Parameters

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
removeListener (type:string, listener:Function) :void

Removes a listener from the Emitter object.

Parameters

  1. type:string –
  2. listener:Function –

Throws

  • TypeError –
removeAllListeners (type:string) :void

Removes all listeners from the Emitter for the specified event.

Parameters

  1. type:string –

Throws

  • TypeError –
listeners (type:string) :array

Returns an array of listeners for the specified event.

Parameters

  1. type:string –

Returns

  • array –
toString () :string

Returns the string representation of the specified object.

Returns

  • string –
swapDepthAt (index:number) :void

Swap positions with another node at a given index in the parents child list.

Parameters

  1. index:number –

Throws

  • TypeError –
  • RangeError –
swapDepths (node:Node) :void

Swap positions with a sibling node.

Parameters

  1. node:Node –

Throws

  • TypeError –
  • ReferenceError –
swapChildrenAt (index1:number, index2:number) :void

Swaps the child nodes at the two specified index positions in the child list.

Parameters

  1. index1:number –
  2. index2:number –

Throws

  • TypeError –
  • RangeError –
getBounds (targetCoordSpace:Node) :Rectangle|null

The bounding box of a Node is a union of all it's child Sprite's bounds.

Parameters

  1. targetCoordSpace:Node –

Returns

  • Rectangle|null –

Class Functions

isLayer (obj:Object) :boolean

Test if an object is a Layer.

Parameters

  1. obj:Object –

Returns

  • boolean –