Packageimpression.simulation
Interfacepublic interface IRulesEngine extends flash.events.IEventDispatcher

IRulesEngine defines the minimum functionality required by the SimulationPlayer for an object that evaluates simulation interaction.

Methods on an IRulesEngine object will be invoked by the SimulationPlayer when when a user interacts with the simulation user interface. The object will review the the proposed simulation state changes and allow the proposed changes (potentially adding additional changes) or reject them. The object will also receive notifications when the simulation changes state, and should notify the SimulationPlayer by dispatching the SimulationObjectEvent.STATE_READY event when the simulation state matches the state specified by the rules.

Note that, although the rules are provided to the IRulesEngine object as a single String object, the specific format of the rules and the mechanisms used to evaluate user actions and the simulation state is project- and simulation- specific. The sample runtime included in the AS3 DevKit shows only one possible approach.



Public Properties
 PropertyDefined By
  simulationStateReady : Boolean
[read-only] Indicates whether the simulation is in the state specified by the rules.
IRulesEngine
Public Methods
 MethodDefined By
  
cancel():void
Cancels any rules engine processing currently in progress.
IRulesEngine
  
evaluateChangeRequest(simulation:ISimulation, changeData:*):Boolean
Evaluates a proposed change to the simulation state.
IRulesEngine
  
initialize(simulation:ISimulation, rules:String):void
Begins initialization of the rules.
IRulesEngine
  
onSimulationDataChanged(simulation:ISimulation, changeData:*):void
Invoked when the simulation data is changed.
IRulesEngine
Events
 Event Summary Defined By
  Dispatch when rules engine initialization has completed.IRulesEngine
  Dispatch when an interaction should be remediated.IRulesEngine
  Dispatch when an error occurs.IRulesEngine
  Dispatch when the simulation is in the required state.IRulesEngine
Property Detail
simulationStateReadyproperty
simulationStateReady:Boolean  [read-only]

Indicates whether the simulation is in the state specified by the rules.


Implementation
    public function get simulationStateReady():Boolean
Method Detail
cancel()method
public function cancel():void

Cancels any rules engine processing currently in progress.

evaluateChangeRequest()method 
public function evaluateChangeRequest(simulation:ISimulation, changeData:*):Boolean

Evaluates a proposed change to the simulation state.

Note that, if the change is approved, the SimulationPlayer will invoke the simulation object's setData method with the changeData parameter passed to the rules engine. This means that implementers can modify the change data before it is passed to the simulation. If the change is not approved, implementers may wish to dispatch the RulesEngineRemediationRequestEvent.REQUEST_REMEDIATION event so that appropriate feedback may be displayed to the user.

Parameters

simulation:ISimulation — The simulation to evaluate the proposed change against.
 
changeData:* — The proposed change(s).

Returns
Booleantrue if the change is approved, false else.
initialize()method 
public function initialize(simulation:ISimulation, rules:String):void

Begins initialization of the rules. Implementers must dispatch the SimulationObjectEvent.INITIALIZATION_COMPLETE event when rules engine initialization has completed.

Parameters

simulation:ISimulation — The simulation to evaluate the rules against.
 
rules:String — The rules to use for evaluation.

onSimulationDataChanged()method 
public function onSimulationDataChanged(simulation:ISimulation, changeData:*):void

Invoked when the simulation data is changed.

Implementers must dispatch the SimulationObjectEvent.STATE_READY event when the simulation state matches the state defined by the rules.

Parameters

simulation:ISimulation — Required. An object that implements ISimulation interface.
 
changeData:* — Required. An object containing the data that was changed.

Event Detail
initializationComplete Event
Event Object Type: impression.events.SimulationObjectEvent
SimulationObjectEvent.type property = impression.events.SimulationObjectEvent.INITIALIZATION_COMPLETE

Dispatch when rules engine initialization has completed.

The SimulationObjectEvent.INITIALIZATION_COMPLETE constant defines the value of the type property of a simulation object initialization complete 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.
rulesEngineRequestRemediation Event  
Event Object Type: impression.events.RulesEngineRemediationRequestEvent
RulesEngineRemediationRequestEvent.type property = impression.events.RulesEngineRemediationRequestEvent.REQUEST_REMEDIATION

Dispatch when an interaction should be remediated.

The RulesEngineRemediationRequestEvent.REQUEST_REMEDIATION 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.
messageThe remediation message to display.
remediationDataAdditional remediation data.
simulationObjectError Event  
Event Object Type: impression.events.SimulationObjectErrorEvent
SimulationObjectErrorEvent.type property = impression.events.SimulationPlayerErrorEvent.ERROR

Dispatch when an error occurs.

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.
simulationStateReady Event  
Event Object Type: impression.events.SimulationObjectEvent
SimulationObjectEvent.type property = impression.events.SimulationObjectEvent.STATE_READY

Dispatch when the simulation is in the required state.

The SimulationObjectEvent.STATE_READY constant defines the value of the type property of a simulation object state ready 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.