Package | impression.players |
Class | public class CanvasPlayer |
Inheritance | CanvasPlayer ![]() ![]() ![]() |
Note that events explicitly defined in the CanvasElement documentation are raised by both the CanvasElement and the CanvasPlayer. You should avoid adding event listeners for these events to both the CanvasPlayer and the CanvasElement objects; if you do, unexpected results may occur.
Property | Defined By | ||
---|---|---|---|
![]() | alwaysCheckComplete : Boolean
Specifies how the object should handle storyboard completion. | BasePlayer | |
![]() | narrationComplete : Boolean
Indicates whether narration has finished playing. | BasePlayer | |
![]() | renderingSurface : Sprite
The object to render content on. | RenderingPlayer | |
resolver : AssetResolver [override]
The AssetResolver to use to request external assets. | CanvasPlayer | ||
![]() | storyboard : Storyboard [override]
The storyboard associated with the player. | RenderingPlayer |
Method | Defined By | ||
---|---|---|---|
CanvasPlayer(renderingSurface:Sprite = null, resolver:AssetResolver = null)
Creates a new instance of the CanvasPlayer. | CanvasPlayer | ||
![]() | checkForComplete():void
Causes the player to examine the completion criteria for the current storyboard. | BasePlayer | |
clearElementStyle(action:String, state:String, style:String):void
Deletes a CanvasElement style property. | CanvasPlayer | ||
![]() | clearStyle(style:String):void
Deletes a style property, reverting it back to its default value. | RenderingPlayer | |
deactivateAllExcept(exception:* = null):void
Sets the active property of each CanvasElement except exception to false. | CanvasPlayer | ||
elementOf(item:*):CanvasElement
Returns the CanvasElement associated with an item. | CanvasPlayer | ||
getElementArray():Array
Returns an Array containing the CanvasElement objects on the rendering surface. | CanvasPlayer | ||
getElementStyle(action:String, state:String, style:String):Object
Retrieves a CanvasElement style property. | CanvasPlayer | ||
getElementStyleDefinition():Object [static]
Retrieves the default style map for CanvasElement objects. | CanvasPlayer | ||
getStoryboardState(sb:Storyboard):String [static]
Creates a string describing the state of the storyboard. | CanvasPlayer | ||
![]() | getStyle(style:String):Object
Retrieves a style property. | RenderingPlayer | |
getStyleDefinition():Object [static]
Retrieves the default style map for the CanvasPlayer. | CanvasPlayer | ||
![]() | redraw():void
Forces a complete redraw of the content. | RenderingPlayer | |
resetStoryboard(sb:Storyboard):void [static]
Removes all properties set by the player. | CanvasPlayer | ||
setElementStyle(action:String, state:String, style:String, value:Object):void
Sets a CanvasElement style property. | CanvasPlayer | ||
setStoryboardState(sb:Storyboard, state:String):void [static] | CanvasPlayer | ||
![]() | setStyle(style:String, value:Object):void
Sets a style property. | RenderingPlayer |
Method | Defined By | ||
---|---|---|---|
detachSurface():void [override]
Removes any connections between the rendering surface and the player. | CanvasPlayer | ||
eraseSurface():void [override]
Removes all content from the surface. | CanvasPlayer | ||
![]() | initializeStoryboard():void
Initializes the storyboard. | BasePlayer | |
loadStoryboard():void [override]
Loads the storyboard. | CanvasPlayer | ||
![]() | maskSurface():void
Adds a mask to the rendering surface if the maskRenderingSurface style property value is true. | RenderingPlayer | |
[override]
Removes known completion criteria from the CompleteRemaining storyboard persisted property. | CanvasPlayer | ||
![]() | renderBackground():void
Draws the background rectangle onto the rendering surface. | RenderingPlayer | |
renderContent():void [override]
Renders the content onto the surface. | CanvasPlayer | ||
unloadStoryboard():void [override]
Performs cleanup actions when a storyboard is unloaded. | CanvasPlayer |
Event | Summary | Defined By | ||
---|---|---|---|---|
![]() | Dispatched when the BasePlayer needs to resolve completion criteria beyond those defined for the class. | BasePlayer | ||
![]() | Dispatched when a storyboard is marked as complete. | BasePlayer | ||
![]() | Dispatched when the player begins to load external assets. | RenderingPlayer | ||
![]() | Dispatched when all external assets have finished loading. | RenderingPlayer | ||
![]() | Dispatched when some type of input or output failure occurs. | RenderingPlayer | ||
Dispatched when an element's active property is changed to true. | CanvasPlayer | |||
Dispatched when an element is first created. | CanvasPlayer | |||
Dispatched when an element's complete property is changed to true. | CanvasPlayer | |||
Dispatched when an element completes loading of a graphic. | CanvasPlayer | |||
Dispatched when an element begins loading of a graphic. | CanvasPlayer | |||
Dispatched when an element is redrawn. | CanvasPlayer | |||
![]() | Dispatched after a storyboard is initialized. | BasePlayer | ||
![]() | Dispatched when some type of input or output failure occurs. | RenderingPlayer | ||
![]() | Dispatched when storyboard loading is complete. | BasePlayer | ||
![]() | Dispatched when a storyboard is loaded, but before any processing occurs. | BasePlayer | ||
Dispatched when an element needs to determine the aggregate status of a location. | CanvasPlayer | |||
![]() | Dispatched when some type of input or output failure occurs. | RenderingPlayer | ||
![]() | Dispatched before a storyboard is unloaded. | BasePlayer | ||
![]() | Dispatched when some type of input or output failure occurs. | RenderingPlayer |
Style | Description | Defined By | ||
---|---|---|---|---|
![]() | Type: Boolean Whether or not the primary asset should be resized when loaded to width x height . | RenderingPlayer | ||
![]() | Type: Number The background color transparency of the rendering surface. | RenderingPlayer | ||
![]() | Type: uint Format: Color The background color of the rendering surface. | RenderingPlayer | ||
![]() | Type: Boolean The value of all assets' cacheAsBitmap property that the player should set once the asset is loaded. | RenderingPlayer | ||
![]() | Type: Object The default LoaderContext object to use when assets are loaded. | RenderingPlayer | ||
enableAllDestinations | Type: Boolean Specifies which elements should be enabled. If this style value is false . | CanvasPlayer | ||
![]() | Type: Number Format: Length The height of the rendering surface, in pixels. | RenderingPlayer | ||
![]() | Type: Boolean Whether or not the rendering surface should be masked to width x height . | RenderingPlayer | ||
multipleActivation | Type: Boolean Specifies whether or not multiple canvas elements can be active at the same time. If this style value is false . | CanvasPlayer | ||
![]() | Type: Number Format: Length The width of the rendering surface, in pixels. | RenderingPlayer |
resolver | property |
resolver:AssetResolver
[override]
The AssetResolver to use to request external assets. When this value is set to a non-null
value,
the player registers itself with the resolver as an owner, and all content requested is requested using itself
as the owner.
If the player is currently loading content, all load actions in progress will be cancelled when
this property is set. When removing the references to an existing resolver, the player will unregister itself
as an owner. If the new property value is not null
, the player will register itself as an owner.
public function get resolver():AssetResolver
public function set resolver(value:AssetResolver):void
CanvasPlayer | () | Constructor |
public function CanvasPlayer(renderingSurface:Sprite = null, resolver:AssetResolver = null)
Creates a new instance of the CanvasPlayer.
ParametersrenderingSurface:Sprite (default = null ) — The object to render content on.
| |
resolver:AssetResolver (default = null ) — The AssetResolver to use to request external assets.
|
clearElementStyle | () | method |
public function clearElementStyle(action:String, state:String, style:String):void
Deletes a CanvasElement style property.
If action
is null
or the empty string (""), the
style property referenced is the default style property value to use for all actions. If
action
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with an action
property value of action
. If state
is null
or the empty
string, the style property referenced is the default style property value to use for all states.
If state
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with a state
property value of state
.
The style
parameter value should be one of the styles defined in the CanvasElement object.
Note that, for the purposes of retrieving a specific style, the CanvasElementStates.ACTIVE
and
CanvasElementStates.ACTIVE
state values are identical.
Refer to the documentation on the CanvasElement object's redraw()
method for more information
on the style lookup rules for a CanvasElement.
Parameters
action:String — The action associated with the style.
| |
state:String — The state associated with the style.
| |
style:String — The name of the style property.
|
See also
deactivateAllExcept | () | method |
public function deactivateAllExcept(exception:* = null):void
Sets the active
property of each CanvasElement except exception
to false
.
Invoking this method may cause the element to be redrawn.
Parameters
exception:* (default = null ) — An expression identifying the item to exclude. exception can be one of the following types:
|
See also
detachSurface | () | method |
override protected function detachSurface():void
Removes any connections between the rendering surface and the player.
This method is invoked by the player when a storyboard is unloaded, the redraw()
method is
invoked, or the renderingSurface
property is changed. When detaching a rendering surface, the
CanvasPlayer performs the following actions:
See also
elementOf | () | method |
public function elementOf(item:*):CanvasElement
Returns the CanvasElement associated with an item.
If an element cannot be found, or renderingSurface
is null
, null
is returned.
Parameters
item:* — An expression identifying the item to find the CanvasElement for. item can be one of the following types:
|
CanvasElement — The CanvasElement associated with item .
|
eraseSurface | () | method |
override protected function eraseSurface():void
Removes all content from the surface.
This method is invoked by the player when a storyboard is unloaded or when the redraw()
method is
invoked. When erasing a rendering surface, the CanvasPlayer performs the following actions:
See also
getElementArray | () | method |
public function getElementArray():Array
Returns an Array containing the CanvasElement objects on the rendering surface.
ReturnsArray — An Array containing the CanvasElement objects on the rendering surface.
|
getElementStyle | () | method |
public function getElementStyle(action:String, state:String, style:String):Object
Retrieves a CanvasElement style property.
If action
is null
or the empty string (""), the
style property referenced is the default style property value to use for all actions. If
action
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with an action
property value of action
. If state
is null
or the empty
string, the style property referenced is the default style property value to use for all states.
If state
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with a state
property value of state
.
The style
parameter value should be one of the styles defined in the CanvasElement object.
Note that, for the purposes of retrieving a specific style, the CanvasElementStates.ACTIVE
and
CanvasElementStates.ACTIVE
state values are identical.
Refer to the documentation on the CanvasElement object's redraw()
method for more information
on the style lookup rules for a CanvasElement.
Parameters
action:String — The action associated with the style.
| |
state:String — The state associated with the style.
| |
style:String — The name of the style property.
|
Object — Style value.
|
See also
getElementStyleDefinition | () | method |
public static function getElementStyleDefinition():Object
Retrieves the default style map for CanvasElement objects.
ReturnsObject — Default CanvasElement styles object.
|
See also
getStoryboardState | () | method |
public static function getStoryboardState(sb:Storyboard):String
Creates a string describing the state of the storyboard.
This method returns a single character to describe
the state of the storyboard. If the storyboard is marked complete,
"c
" is returned. If the storyboard has been
initialized, but is not marked complete, "i
" is
returned. Otherwise ".
" is returned.
Note that this string only describes the state that the player is aware of. If the shell stores additional data in the storyboard, it is the shell's responsibility to store the additional data if it is needed.
Parameters
sb:Storyboard — The storyboard to describe the state of.
|
String — The state of the storyboard.
|
getStyleDefinition | () | method |
public static function getStyleDefinition():Object
Retrieves the default style map for the CanvasPlayer.
ReturnsObject — Default styles object.
|
See also
loadStoryboard | () | method |
override protected function loadStoryboard():void
Loads the storyboard.
This method is invoked by the storyboard
property set method when a non-null
storyboard object is loaded after initialization (if needed) occurs.
When loading a storyboard, the CanvasPlayer performs the following actions:
Active
persisted property of each ChildElement in the storyboard's children
collection is set to false
.alwaysCheckComplete
property value is true
, the Complete
persisted property of each ChildElement in the storyboard's children
collection is set to false
.See also
removeCompleteRemainingCriteria | () | method |
override protected function removeCompleteRemainingCriteria():void
Removes known completion criteria from the CompleteRemaining
storyboard persisted property.
This method is invoked by the checkForComplete()
method if the value of the storyboard
property is not null
, and the complete
event has not been dispatched since the storyboard
was loaded.
In addition to the substrings processed by the BasePlayer, the CanvasPlayer will remove the following substrings from the completeRemaining
persisted property:
Substring | Meaning |
---|---|
destinationsComplete; | All CanvasElements with an ActionType property value of CanvasElementActionTypes.JUMP or CanvasElementActionTypes.DISPLAY_RANGE have their Complete persisted property set to true . |
commandsComplete; | All CanvasElements with an ActionType property value of CanvasElementActionTypes.POPUP_TEXT or CanvasElementActionTypes.POPUP_GRAPHIC have their Complete persisted property set to true . |
popupsShown; | All CanvasElements with an ActionType property value of CanvasElementActionTypes.PLAY_SOUND , CanvasElementActionTypes.HYPERLINK , or CanvasElementActionTypes.COMMAND have their Complete persisted property set to true . |
See also
renderContent | () | method |
override protected function renderContent():void
Renders the content onto the surface.
To render content, the CanvasPlayer performs the following actions:
children
collection.CanvasElementEvent.ELEMENT_INITIALIZE
event.redraw()
method.resetStoryboard | () | method |
public static function resetStoryboard(sb:Storyboard):void
Removes all properties set by the player.
Note that this method also removes interim completion properties used by the player, but not necessarily set by the player.
Parameters
sb:Storyboard — The storyboard to remove properties from.
This method removes the following properties from a storyboard:
This method removes the following properties from each ChildElement in the storyboard's
|
See also
setElementStyle | () | method |
public function setElementStyle(action:String, state:String, style:String, value:Object):void
Sets a CanvasElement style property.
If action
is null
or the empty string (""), the
style property referenced is the default style property value to use for all actions. If
action
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with an action
property value of action
. If state
is null
or the empty
string, the style property referenced is the default style property value to use for all states.
If state
is not null
or the empty string, the style property
referenced is the style property value to use for all CanvasElements with a state
property value of state
.
The style
parameter value should be one of the styles defined in the CanvasElement object.
Note that, for the purposes of retrieving a specific style, the CanvasElementStates.ACTIVE
and
CanvasElementStates.ACTIVE
state values are identical.
Refer to the documentation on the CanvasElement object's redraw()
method for more information
on the style lookup rules for a CanvasElement.
Parameters
action:String — The action associated with the style.
| |
state:String — The state associated with the style.
| |
style:String — The name of the style property.
| |
value:Object |
See also
setStoryboardState | () | method |
public static function setStoryboardState(sb:Storyboard, state:String):void
Parameters
sb:Storyboard | |
state:String |
unloadStoryboard | () | method |
override protected function unloadStoryboard():void
Performs cleanup actions when a storyboard is unloaded.
This method is invoked by the storyboard
property set method when the current value of the property
is not null
and the unload
event has not been cancelled.
When unloading a storyboard, the CanvasPlayer performs the following actions:
See also
elementActive | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_ACTIVE
Dispatched when an element's active
property is changed to true
.
Property | Value |
---|---|
bubbles | true |
cancelable | true ; canceling this event object suppresses redraw of the element. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
See also
elementActive | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_INITIALIZE
Dispatched when an 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:Property | Value |
---|---|
bubbles | true |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
See also
elementComplete | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_COMPLETE
Dispatched when an element's complete
property is changed to true
.
Property | Value |
---|---|
bubbles | true |
cancelable | true ; canceling this event object suppresses redraw of the element. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
See also
elementGraphicLoadComplete | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_COMPLETE
Dispatched when an 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:Property | Value |
---|---|
bubbles | true |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
elementGraphicLoadInit | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_GRAPHIC_LOAD_INIT
Dispatched when an 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:Property | Value |
---|---|
bubbles | true |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
elementRedraw | Event |
impression.events.CanvasElementEvent
impression.events.CanvasElementEvent.ELEMENT_REDRAW
Dispatched when an 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:Property | Value |
---|---|
bubbles | true |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
canvasElement | The CanvasElement object assigned to the target. |
action | The value of the action property of canvasElement . |
See also
locationStatusRequest | Event |
impression.events.LocationStatusRequestEvent
impression.events.LocationStatusRequestEvent.LOCATION_STATUS_REQUEST
Dispatched when an element needs to determine the aggregate status of a location. This event is dispatched if an element's 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.
Property | Value |
---|---|
bubbles | false |
cancelable | false ; there is no default behavior to cancel. |
currentTarget | The object that is actively processing the Event object with an event listener. |
target | The object that raised the event. |
sb | The Storyboard object assigned to the target. |
location | The location to determine the status of. |
status |