Packageimpression.players
Classpublic class CanvasElement
InheritanceCanvasElement Inheritance flash.display.Sprite

The CanvasElement class represents an individual display element on a Canvas. Note that CanvasElements should only be created by a Canvas.

A CanvasElement may have an associated action. Note that the shell, not the CanvasElement, is responsible for triggering the action. Shell authors may listen for events either directly from the CanvasElement or from the renderingSurface of the Canvas itself to trigger actions—all CanvasElement events have their bubbles property value set to true.



Public Properties
 PropertyDefined By
  action : String
[read-only] Indicates the action type associated with the object.
CanvasElement
  active : Boolean
Indicates whether the object is active.
CanvasElement
  canvas : CanvasPlayer
[read-only] The CanvasPlayer associated with this object.
CanvasElement
  childElement : ChildElement
[read-only] The ChildElement associated with this object.
CanvasElement
  complete : Boolean
Indicates whether the object is complete.
CanvasElement
  hasLink : Boolean
[read-only] Indicates whether the element has a clickable link.
CanvasElement
  resolver : AssetResolver
[read-only] The AssetResolver associated with this object.
CanvasElement
  state : String
[read-only] Indicates the state of the object.
CanvasElement
Public Methods
 MethodDefined By
  
clearStyle(state:String, style:String):void
Deletes a style property.
CanvasElement
  
getStyle(state:String, style:String):Object
Retrieves a style property.
CanvasElement
  
[static] Retrieves the default style map for the element.
CanvasElement
  
redraw():void
Redraws the element.
CanvasElement
  
setStyle(state:String, style:String, value:Object):void
Sets a style property.
CanvasElement
Events
 Event Summary Defined By
  Dispatched when the element encounters an error while loading a graphic.CanvasElement
  Dispatched when the element's active property is changed to true.CanvasElement
  Dispatched when the element is first created.CanvasElement
  Dispatched when the element's complete property is changed to true.CanvasElement
  Dispatched when the element completes loading of a graphic.CanvasElement
  Dispatched when the element begins loading of a graphic.CanvasElement
  Dispatched when the element is redrawn.CanvasElement
  Dispatched when the element encounters an error while loading a graphic.CanvasElement
  Dispatched when the element needs to determine the aggregate status of a location.CanvasElement
  Dispatched when the element encounters an error while loading a graphic.CanvasElement
  Dispatched when the element encounters an error while loading a graphic.CanvasElement
Styles
 Style Description Defined By
  
antiAliasType
Type: flash.text.AntiAliasType
Indicates the type of antialiasing that used be used by the text field for text elements. The default value is AntiAliasType.ADVANCED.
CanvasElement
  
cacheAsBitmap
Type: Boolean
Indicates the value of the element's cacheAsBitmap property. The default value is true.

See also

flash.display.DisplayObject.cacheAsBitmap
CanvasElement
  
doubleClickEnabled
Type: Boolean
Specifies whether double-clicking on the element is enabled. The default value is true.
CanvasElement
  
embedFonts
Type: Boolean
Indicates whether embedded fonts should be used for text elements. The default value is false.
CanvasElement
  
fontBold
Type: Boolean
The bold state of the font used for text elements when a custom font is not requested. The default value is false.
CanvasElement
  
fontItalic
Type: Boolean
The italic state of the font used for text elements when a custom font is not requested. The default value is false.
CanvasElement
  
fontName
Type: String
The default font family name used for text elements when a custom font is not requested. The default value is "Arial".
CanvasElement
  
fontSize
Type: Number
The size, in pixels, used for text elements when a custom font is not requested. The default value is 14.
CanvasElement
  
fontUnderline
Type: Boolean
The underline state of the font used for text elements when a custom font is not requested. The default value is false.
CanvasElement
  
htmlText
Type: Boolean
Indicates whether the text property of the element should be treated as HTML text. The default value is false.
CanvasElement
  
shapeColor
Type: uint Format: Color
The color used for shape elements when a custom color is not requested. The default value is 0x000000.
CanvasElement
  
shapeThickness
Type: Number Format: Length
Indicates the thickness of shape elements, in pixels. The default value is 2.
CanvasElement
  
styleSheet
Type: flash.text.StyleSheet
The style sheet to use for text elements. Note that the stylesheet, if present, is set after the other text-related styles. The default value is null.
CanvasElement
  
textColor
Type: uint Format: Color
The color used for text elements when a custom color is not requested. The default value is 0x000000.
CanvasElement
  
useHandCursor
Type: Boolean
Indicates whether the element should display the hand cursor. The default value is true.
CanvasElement
  
useLinks
Type: Boolean
Indicates how embedded hyperlinks should be handled. If this value is true, and the htmlText style property is true, and the text property of the element includes a hyperlink, clicking on the embedded text field will result in the text field dispatching a flash.events.TextEvent.LINK event if the area clicked on is part of the hyperlink, or a flash.events.MouseEvent.CLICK event if it is not. If this value is false, mouse input for the embedded text field is disabled, and any mouse events will be dispatched by the element itself. The default value is false.
CanvasElement
Property Detail
actionproperty
action:String  [read-only]

Indicates the action type associated with the object. This property value will be one of the CanvasElementActionType constants.


Implementation
    public function get action():String

See also

activeproperty 
active:Boolean

Indicates whether the object is active.

Changing this property value causes the childElement property's active persisted property to be changed to the new value.

If this property value is changed from false to true, the childElement property's complete persisted property is set to true and the CanvasElementEvent.ELEMENT_ACTIVE event is dispatched by the element. If the event is not cancelled, the element is redrawn. If this property value is changed from true to false, no event is dispatched, and the element is redrawn.

Note that if this property changes the ChildElement's complete persisted property to true, the CanvasElementEvent.ELEMENT_COMPLETE event is not dispatched.

If the action property value is CanvasElementActionTypes.JUMP or CanvasElementActionTypes.DISPLAY_RANGE, the persisted property value is set, but no other action occurs.


Implementation
    public function get active():Boolean
    public function set active(value:Boolean):void

See also

canvasproperty 
canvas:CanvasPlayer  [read-only]

The CanvasPlayer associated with this object.


Implementation
    public function get canvas():CanvasPlayer
childElementproperty 
childElement:ChildElement  [read-only]

The ChildElement associated with this object.


Implementation
    public function get childElement():ChildElement
completeproperty 
complete:Boolean

Indicates whether the object is complete.

Changing this property value causes the childElement property's complete persisted property to be changed to the new value and the element is redrawn. If the action property value is CanvasElementActionTypes.JUMP or CanvasElementActionTypes.DISPLAY_RANGE, changes to this property value are ignored.

If this property value is changed from false to true, the CanvasElementEvent.ELEMENT_COMPLETE is dispatched by the element.


Implementation
    public function get complete():Boolean
    public function set complete(value:Boolean):void

See also

hasLinkproperty 
hasLink:Boolean  [read-only]

Indicates whether the element has a clickable link.


Implementation
    public function get hasLink():Boolean

See also

resolverproperty 
resolver:AssetResolver  [read-only]

The AssetResolver associated with this object.


Implementation
    public function get resolver():AssetResolver
stateproperty 
state:String  [read-only]

Indicates the state of the object. This property value will be one of the CanvasElementState constants.

If the value of the action property is CanvasElementActionTypes.JUMP or CanvasElementActionTypes.DISPLAY_RANGE, the property value will be based on the aggregate status of the destination, as stored in the ChildElement property's DestinationStatus persistedn property. For all other action types, the property value is based on the state of the active and complete properties. Note that if an element is active, the value of the is property is ACTIVE. If the element is not active, but is complete, the value of the is property is COMPLETE. If the element is neither active nor complete, the value of the is property is DEFAULT.


Implementation
    public function get state():String

See also

Method Detail
clearStyle()method
public function clearStyle(state:String, style:String):void

Deletes a style property.

Parameters

state:String — The state property value associated with the style.
 
style:String — The name of the style property.

See also

getStyle()method 
public function getStyle(state:String, style:String):Object

Retrieves a style property.

If state is one of the CanvasElementStates constant values, the style property referenced is the style property value to use when the state property matches the state parameter. If state is any other value, the style property referenced is the style property value to use as a default value for all states.

Note that a default style property value set using this method will override an action- or state-specific style property value defined in the Canvas.

Parameters

state:String — The state property value associated with the style.
 
style:String — The name of the style property.

Returns
Object — Style value.

See also

getStyleDefinition()method 
public static function getStyleDefinition():Object

Retrieves the default style map for the element.

Note that values from the default style map are used only if no value for a style was set using the object's setStyle() method or the CanvasPlayer's setElementStyle() method.

Returns
Object — Default styles object.

See also

redraw()method 
public function redraw():void

Redraws the element.

When looking up a style to use for drawing, the CanvasElement determines the style value to use according to the following rules:

Once the element is drawn, the CanvasElementEvent.ELEMENT_REDRAW event is dispatched.

See also

setStyle()method 
public function setStyle(state:String, style:String, value:Object):void

Sets a style property.

If state is one of the CanvasElementStates constant values, the style property referenced is the style property value to use when the state property matches the state parameter. If state is any other value, the style property referenced is the style property value to use as a default value for all states.

Note that a default style property value set using this method will override an action- or state-specific style property value defined in the Canvas.

Parameters

state:String — The state property value associated with the style.
 
style:String — The name of the style property.
 
value:Object — The value of the style.

See also

Event Detail
diskError Event
Event Object Type: flash.errors.IOErrorEvent
IOErrorEvent.type property = flash.errors.IOErrorEvent.DISK_ERROR

Dispatched when the element encounters an error while loading a graphic.

elementActive Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_ACTIVE

Dispatched when the element's active property is changed to true.

The CanvasElementEvent.ELEMENT_ACTIVE constant defines the value of the type property of a element active event object. This event has the following properties:
PropertyValue
bubblestrue
cancelabletrue; canceling this event object suppresses redraw of the element.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.

See also

elementActive Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_INITIALIZE

Dispatched when the element is first created.

The CanvasElementEvent.ELEMENT_INITIALIZE constant defines the value of the type property of a element initialized event object. This event has the following properties:
PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.

See also

elementComplete Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_COMPLETE

Dispatched when the element's complete property is changed to true.

The CanvasElementEvent.ELEMENT_COMPLETE constant defines the value of the type property of a element complete event object. This event has the following properties:
PropertyValue
bubblestrue
cancelabletrue; canceling this event object suppresses redraw of the element.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.

See also

elementGraphicLoadComplete Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_COMPLETE

Dispatched when the element completes loading of a graphic.

The CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_COMPLETE constant defines the value of the type property of a element graphic load complete event object. This event has the following properties:
PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.
elementGraphicLoadInit Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_INIT

Dispatched when the element begins loading of a graphic.

The CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_INIT constant defines the value of the type property of a element graphic load init event object. This event has the following properties:
PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.
elementRedraw Event  
Event Object Type: impression.events.CanvasElementEvent
CanvasElementEvent.type property = impression.events.CanvasElementEvent.ELEMENT_REDRAW

Dispatched when the element is redrawn.

The CanvasElementEvent.ELEMENT_REDRAW constant defines the value of the type property of a element redraw event object. This event has the following properties:
PropertyValue
bubblestrue
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
canvasElementThe CanvasElement object assigned to the target.
actionThe value of the action property of canvasElement.

See also

ioError Event  
Event Object Type: flash.errors.IOErrorEvent
IOErrorEvent.type property = flash.errors.IOErrorEvent.IO_ERROR

Dispatched when the element encounters an error while loading a graphic.

locationStatusRequest Event  
Event Object Type: impression.events.LocationStatusRequestEvent
LocationStatusRequestEvent.type property = impression.events.LocationStatusRequestEvent.LOCATION_STATUS_REQUEST

Dispatched when the element needs to determine the aggregate status of a location. This event is dispatched if the action property value is CanvasElementActionTypes.JUMP or CanvasElementActionTypes.DISPLAY_RANGE, and is dispatched when the element is redrawn.

If the aggregate status is LocationStatusTypes.COMPLETE, the complete property is set to true and the CanvasElementEvent.ELEMENT_COMPLETE event is dispatched.

The LocationStatusRequestEvent.LOCATION_STATUS_REQUEST constant defines the value of the type property of a location status request event object. This event has the following properties:
PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object that raised the event.
sbThe Storyboard object assigned to the target.
locationThe location to determine the status of.
status
networkError Event  
Event Object Type: flash.errors.IOErrorEvent
IOErrorEvent.type property = flash.errors.IOErrorEvent.NETWORK_ERROR

Dispatched when the element encounters an error while loading a graphic.

verifyError Event  
Event Object Type: flash.errors.IOErrorEvent
IOErrorEvent.type property = flash.errors.IOErrorEvent.VERIFY_ERROR

Dispatched when the element encounters an error while loading a graphic.