Packageimpression.players
Classpublic class SimulationPlayer
InheritanceSimulationPlayer Inheritance BasePlayer Inheritance flash.events.EventDispatcher

The SimulationPlayer supports playback of simulation storyboards.

The Impression simulation framework provides a flexible, robust mechanism for defining simulation objects and managing student interaction with these objects. The SimulationPlayer uses program-specific objects (using interfaces defined in the impression.simulation namespace) to control simulation state and monitor and control interactions. The samples included with the AS3 Base Class Framework illustrate just one way of many to create and use these objects to provide a rich, interactive simulation environment for learning.



Public Properties
 PropertyDefined By
  additionalActionsComplete : Boolean
Indicates whether additional, non-simulation state actions have been completed.
SimulationPlayer
  alwaysCheckComplete : Boolean
[override] Specifies how the object should handle storyboard completion.
SimulationPlayer
  loading : Boolean
[read-only] Indicates whether the current storyboard is loading.
SimulationPlayer
 InheritednarrationComplete : Boolean
Indicates whether narration has finished playing.
BasePlayer
  remediationCount : Number
The number of times that a remediation event has occurred for the current storyboard.
SimulationPlayer
  resolver : AssetResolver
The AssetResolver to use to request external assets.
SimulationPlayer
  rulesEngine : IRulesEngine
The simulation rules engine.
SimulationPlayer
  sequencer : ISequencer
The simulation sequencer.
SimulationPlayer
  simulation : ISimulation
The simulation process.
SimulationPlayer
  simulationUI : ISimulationUI
The simulation user interface.
SimulationPlayer
  snapshotLoader : ISnapshotLoader
The simulation snapshot loader.
SimulationPlayer
  storyboard : Storyboard
[override] Specifies the storyboard for the player.
SimulationPlayer
Public Methods
 MethodDefined By
  
SimulationPlayer(sim:ISimulation = null, simUI:ISimulationUI = null, snapshotLoader:ISnapshotLoader = null, sequencer:ISequencer = null, rulesEngine:IRulesEngine = null, resolver:AssetResolver = null)
Creates a new instance of the SimulationPlayer.
SimulationPlayer
  
[override] Causes the player to examine the completion criteria for the current storyboard.
SimulationPlayer
  
[static] Creates a string describing the state of the storyboard.
SimulationPlayer
  
requestDataChange(changeData:Object):Boolean
Processes a request for a change to the simulation data.
SimulationPlayer
  
[static] Removes all properties set by the player.
SimulationPlayer
  
setStoryboardState(sb:Storyboard, state:String):void
[static] Modifies the storyboard to match the described state passed.
SimulationPlayer
Protected Methods
 MethodDefined By
 Inherited
Initializes the storyboard.
BasePlayer
  
[override] Loads the storyboard.
SimulationPlayer
  
[override] Removes known completion criteria from the CompleteRemaining storyboard persisted property.
SimulationPlayer
  
[override] Performs cleanup actions when a storyboard is unloaded.
SimulationPlayer
Events
 Event Summary Defined By
 InheritedDispatched when the BasePlayer needs to resolve completion criteria beyond those defined for the class.BasePlayer
 InheritedDispatched when a storyboard is marked as complete.BasePlayer
  Dispatched when the snapshot loader begins to load external assets.SimulationPlayer
  Dispatched when all external assets have finished loading.SimulationPlayer
  Dispatched when the rules engine approves a data change request.SimulationPlayer
 InheritedDispatched after a storyboard is initialized.BasePlayer
 InheritedDispatched when storyboard loading is complete.BasePlayer
 InheritedDispatched when a storyboard is loaded, but before any processing occurs.BasePlayer
  Dispatched when the rules engine determines that remediation should occur.SimulationPlayer
  Dispatched when an simulation-related object dispatches an error event.SimulationPlayer
 InheritedDispatched before a storyboard is unloaded.BasePlayer
Property Detail
additionalActionsCompleteproperty
additionalActionsComplete:Boolean

Indicates whether additional, non-simulation state actions have been completed.

If the storyboard property value is null, false is returned. This method sets or returns the value of the current storyboard's additionalActionsComplete persisted property.


Implementation
    public function get additionalActionsComplete():Boolean
    public function set additionalActionsComplete(value:Boolean):void
alwaysCheckCompleteproperty 
alwaysCheckComplete:Boolean[override]

Specifies how the object should handle storyboard completion.

If this property value is true, the value of the CompleteRemaining persisted property is set to the value of the CompleteWhen persisted property each time the storyboard is loaded. In addition, any interim completion flags are removed. This causes the checkForComplete() method to perform normal processing of the storyboard's completion criteria. When all criteria have been met, the method will then dispatch the complete event, regardless of the value of the complete persisted property.

If this property value is false, the value of the CompleteRemaining persisted property is set only on initialization and the complete event will be dispatched only if the Complete persisted property value was previously false.

Regardless of the value of this property, the complete event will only be dispatched once while the storyboard is loaded by the player.

Note that the SimulationPlayer default value for this property is true.

The default value is true.


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

See also

loadingproperty 
loading:Boolean  [read-only]

Indicates whether the current storyboard is loading.


Implementation
    public function get loading():Boolean
remediationCountproperty 
remediationCount:Number

The number of times that a remediation event has occurred for the current storyboard.

If the storyboard property value is null, -1 is returned. Note that this number can be changed by the shell when the player dispatches a RemediationRequestEvent.REMEDIATION_REQUEST event. This method sets or returns the value of the current storyboard's RemediationCount persisted property.


Implementation
    public function get remediationCount():Number
    public function set remediationCount(value:Number):void

See also

resolverproperty 
resolver:AssetResolver

The AssetResolver to use to request external assets.

The resolver is not used directly by the SimulationPlayer, rather, it is passed to the snapshotLoader as needed.


Implementation
    public function get resolver():AssetResolver
    public function set resolver(value:AssetResolver):void

See also

rulesEngineproperty 
rulesEngine:IRulesEngine

The simulation rules engine.


Implementation
    public function get rulesEngine():IRulesEngine
    public function set rulesEngine(value:IRulesEngine):void
sequencerproperty 
sequencer:ISequencer

The simulation sequencer.


Implementation
    public function get sequencer():ISequencer
    public function set sequencer(value:ISequencer):void
simulationproperty 
simulation:ISimulation

The simulation process.


Implementation
    public function get simulation():ISimulation
    public function set simulation(value:ISimulation):void
simulationUIproperty 
simulationUI:ISimulationUI

The simulation user interface.


Implementation
    public function get simulationUI():ISimulationUI
    public function set simulationUI(value:ISimulationUI):void
snapshotLoaderproperty 
snapshotLoader:ISnapshotLoader

The simulation snapshot loader.


Implementation
    public function get snapshotLoader():ISnapshotLoader
    public function set snapshotLoader(value:ISnapshotLoader):void
storyboardproperty 
storyboard:Storyboard[override]

Specifies the storyboard for the player.

If null is passed, the current storyboard is unloaded, the StoryboardEvent.UNLOAD event is dispatched, and no further action occurs.

If a non-null storyboard object is passed, the following actions occur, in order:

  1. If the previously loaded storyboard is not null, the StoryboardEvent.UNLOAD event is dispatched. If the event is not cancelled, the current storyboard is unloaded. If the event is cancelled, further processing stops.
  2. The StoryboardEvent.LOAD_START event is dispatched. If the event is not cancelled, the new storyboard is associated with the player. If the event is cancelled, further processing stops and the value of this property is set to null.
  3. If the value of the new storyboard's Initialized persisted property is false, the storyboard is initialized and the StoryboardEvent.INITIALIZE event is dispatched.
  4. The loadStoryboard() protected method is invoked.


Implementation
    public function get storyboard():Storyboard
    public function set storyboard(value:Storyboard):void

See also

Constructor Detail
SimulationPlayer()Constructor
public function SimulationPlayer(sim:ISimulation = null, simUI:ISimulationUI = null, snapshotLoader:ISnapshotLoader = null, sequencer:ISequencer = null, rulesEngine:IRulesEngine = null, resolver:AssetResolver = null)

Creates a new instance of the SimulationPlayer.

Parameters
sim:ISimulation (default = null) — The simulation process.
 
simUI:ISimulationUI (default = null) — The simulation user interface.
 
snapshotLoader:ISnapshotLoader (default = null) — The simulation snapshot loader.
 
sequencer:ISequencer (default = null) — The simulation sequencer.
 
rulesEngine:IRulesEngine (default = null) — The simulation rules engine.
 
resolver:AssetResolver (default = null) — The AssetResolver to use to request external assets.
Method Detail
checkForComplete()method
override public function checkForComplete():void

Causes the player to examine the completion criteria for the current storyboard.

If the current storyboard is null, invoking this method has no effect. If the current storyboard is still loading (the loading property value is true, invoking this method has no effect.

The method begins by removing known satisfied completion criteria from the completeRemaining persisted property. Once known satisified criteria are removed, ff the persisted property is not empty (""), the CheckForCompleteEvent.CHECK_FOR_COMPLETE event is dispatched, and the property takes the event's completeRemaining property value.

If the completeRemaining property value is empty after the event returns, and the Complete persisted property value is to false or the alwaysCheckComplete property value is true, the Complete persisted property value is set to true and the StoryboardEvent.COMPLETE event is dispatched.

If the alwaysCheckComplete property value is false, and the Complete persisted property value is true, no additional processing will occur after the CheckForCompleteEvent.CHECK_FOR_COMPLETE event is dispatched, and the complete event will not occur.

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.

Returns
String — The state of the storyboard.
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 RenderingPlayer performs the following actions:

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 SimulationPlayer will remove the following substrings from the completeRemaining persisted property:

SubstringMeaning
simulationStateReady;The value of the rules engine's simulationStateReady property is true.
additionalActionsComplete;The value of the additionalActionsComplete property is true.

See also

requestDataChange()method 
public function requestDataChange(changeData:Object):Boolean

Processes a request for a change to the simulation data.

This method is automatically invoked by the SimulationPlayer when the ISimulationUI object referenced by the simulationUI property value dispatches a SimulationDataChangeRequestEvent.DATA_CHANGE_REQUEST event.

If the simulation property value is null, invoking this method has no effect and returns false. If the rulesEngine property value is null, and the simulation object's ownerSetsData property value is true, invoking this method has no effect and returns true. If the rulesEngine property value is null, and the simulation object's ownerSetsData property value is false, this method passes the changeData parameter to the simulation object's setData method and returns true.

If the rulesEngine property value is not null, the simulation property value and the changeData parameter value are passed to the rules engine's evaluateChangeRequest() method. If the method returns true, and the simulation object's ownerSetsData property value is false, the simulation object's setData method is invoked with the changeData parameter. Regardless of the value of the ownerSetsData property value, the player will dispatch a SimulationDataChangeEvent.DATA_CHANGE_APPROVED event if the change is approved by the rules engine. The method will return the result of the call to the rules engine's evaluateChangeRequest() method.

Parameters

changeData:Object — The requested change to evaluate.

Returns
Booleantrue if the change is approved by the rules engine, false else.

See also

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:

  • AdditionalActionsComplete
  • Initialized
  • CompleteRemaining
  • Complete
  • NarrationComplete
  • RemediationCount
  • The Complete property of each ChildElement object in the storyboard's Commands ChildElementCollection property, if it exists.

See also

setStoryboardState()method 
public static function setStoryboardState(sb:Storyboard, state:String):void

Modifies the storyboard to match the described state passed.

If the value of state is "c" (indicating a completed storyboard), interim completion criteria will be marked as complete in addition to the overall storyboard state.

State values created using a function other than getStoryboardState may not work.

Parameters

sb:Storyboard — The Storyboard object to modify.
 
state:String — A String created using the getStoryboardState() method containing the state to restore.

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

storyboard
impression.simulation.ISnapshotLoader.cancel()
impression.simulation.ISequencer.cancel()
impression.simulation.IRulesEngine.cancel()
impression.resolver.assetResolver.cancelOwnerTransaction()
impression.resolver.assetResolver.closeAllOf()
Event Detail
contentLoadBegin Event
Event Object Type: impression.events.StoryboardEvent
StoryboardEvent.type property = impression.events.StoryboardEvent.CONTENT_LOAD_BEGIN

Dispatched when the snapshot loader begins to load external assets.

This event is dispatched when the resolverInfo object whose owner property value is the player dispatches its beginTransaction event.

The StoryboardEvent.CONTENT_LOAD_BEGIN constant defines the value of the type property of a content load begin 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.
contentLoadEnd Event  
Event Object Type: impression.events.StoryboardEvent
StoryboardEvent.type property = impression.events.StoryboardEvent.CONTENT_LOAD_END

Dispatched when all external assets have finished loading.

This event is dispatched when the resolverInfo object whose owner property value is the player dispatches its endTransaction event.

The StoryboardEvent.CONTENT_LOAD_END constant defines the value of the type property of a content load end 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.
dataChangeApproved Event  
Event Object Type: impression.events.SimulationDataChangedEvent
SimulationDataChangedEvent.type property = impression.events.SimulationDataChangedEvent.DATA_CHANGE_APPROVED

Dispatched when the rules engine approves a data change request.

This event is dispatched when the requestDataChange() method is invoked either explicitly or implicitly as the result of the simulationUI property object dispatching a SimulationDataChangeRequestEvent.DATA_CHANGE_REQUEST event. The event is dispatched if the call to the rules engine's evaluateChangeRequest() method returns true.

The SimulationDataChangedEvent.DATA_CHANGE_APPROVED constant defines the value of the type property of a data change approved 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.
changeDataThe data that has changed.
remediationRequest Event  
Event Object Type: impression.events.RemediationRequestEvent
RemediationRequestEvent.type property = impression.events.RemediationRequestEvent.REMEDIATION_REQUEST

Dispatched when the rules engine determines that remediation should occur.

This event is dispatched by the player when the rules engine dispatches a RulesEngineRemediationRequest.REQUEST_REMEDIATION event. Before dispatching the event, the SimulationPlayer will set the value of the remediationCount property of the event object to one more than the value of the current storyboard's remediationCount persisted property. When the event returns, the value of the event's remediationCount property will be stored as the current storyboard's remediationCount persisted property.

The RemediationRequestEvent.REMEDIATION_REQUEST constant defines the value of the type property of a remediation 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.
messageThe remediation message to display.
remediationDataAdditional remediation data.
remediationCountThe number of times remediation requests have occurred for the storyboard.
simulationPlayerError Event  
Event Object Type: impression.events.SimulationPlayerErrorEvent
SimulationPlayerErrorEvent.type property = impression.events.SimulationPlayerErrorEvent.ERROR

Dispatched when an simulation-related object dispatches an error event.

This event is dispatched when the simulation, simulation user interface, snapshot loader, sequencer, or rules engine dispatches a SimulationObjectErrorEvent.ERROR event.

This event is dispatched when the requestDataChange() method is invoked either explicitly or implicitly as the result of the simulationUI property object dispatching a SimulationDataChangeRequestEvent.DATA_CHANGE_REQUEST event. The event is dispatched if the call to the rules engine's evaluateChangeRequest() method returns true.

The SimulationPlayerErrorEvent.ERROR constant defines the value of the type property of an error 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.
loadingIndicates whether or not the event occurred during the loading phase of the storyboard.
messageThe message associated with the error.
errorDataAdditional data associated with the error.
sourceThe type of object that initially raised the error.