Packageimpression.players
Classpublic class MatchingPlayer
InheritanceMatchingPlayer Inheritance BasePlayer Inheritance flash.events.EventDispatcher

The MatchingPlayer class supports playback of matching type storyboards, including matching text to text, matching text to graphics, matching graphics to text, and matching graphics to graphics. A matching storyboard consists of up to five question-answer pairs and a single response distractor. These properties are assigned position indicies, which are used to determine the onscreen ordering of the items.

Once the questions and responses have been placed onscreen, the user will select a question to answer, then select a response. Once one or more questions have been answered, the responses can be evaulated and scored.

The MatchingPlayer class is a face-based player; all drawing and interaction is handled by the shell. Like most face-based players, the MatchingPlayer class is designed to encapsulate the logic required to manage matching questions and make the development of matching question interfaces as simple as possible.



Public Properties
 PropertyDefined By
 InheritedalwaysCheckComplete : Boolean
Specifies how the object should handle storyboard completion.
BasePlayer
  correct : Boolean
[read-only] true if all questions have been correctly evaulated, false else.
MatchingPlayer
  extendedDistractors : Boolean
Specifies how the class should handle selection of invalid question and response indices.
MatchingPlayer
  isPracticeQuestion : Boolean
[read-only] true if the question is marked as a practice question, false else.
MatchingPlayer
  maximumDistractors : int
[static] Indicates the maximum number of distractors to be processed.
MatchingPlayer
  maximumQuestions : int
[static] Indicates the maximum number of question/answer pairs to be processed.
MatchingPlayer
 InheritednarrationComplete : Boolean
Indicates whether narration has finished playing.
BasePlayer
  resetEvaluationOnSelection : Boolean
Specifies how the class should handle selection of previously evaulated questions.
MatchingPlayer
  selectedQuestionIndex : Number
[read-only] The index of the currently selected question.
MatchingPlayer
  selectionsComplete : Boolean
[read-only] true if all questions that have not yet been evaluated have a selected response and at least one question has not yet been evaluated; false else.
MatchingPlayer
  status : String
[read-only] The aggregate status of the questions in the current storyboard.
MatchingPlayer
  storyboard : Storyboard
[override] Specifies the storyboard for the player.
MatchingPlayer
  strictSelection : Boolean
Specifies how the class should handle selection of invalid question and response indices.
MatchingPlayer
  totalQuestions : Number
[read-only] The total number of valid questions in the current storyboard.
MatchingPlayer
  totalResponses : Number
[read-only] The total number of valid responses in the current storyboard.
MatchingPlayer
Public Methods
 MethodDefined By
  
Creates a new instance of the MatchingPlayer.
MatchingPlayer
 Inherited
Causes the player to examine the completion criteria for the current storyboard.
BasePlayer
  
Returns detailed information about the question at index.
MatchingPlayer
  
Returns detailed information about the response at index.
MatchingPlayer
  
evaluate():void
Evaluates the selected responses.
MatchingPlayer
  
[static] Creates a string describing the state of the storyboard.
MatchingPlayer
  
Returns a MatchingSummary object containing aggregate information about the storyboard.
MatchingPlayer
  
indexOf(propertyName:String):Number
Returns the index of the propertyName.
MatchingPlayer
  
isQuestionAtLocked(index:Number):Boolean
Identifies whether the question at index is locked.
MatchingPlayer
  
isResponseAtLocked(index:Number):Boolean
Identifies whether the response at index is locked.
MatchingPlayer
  
lockAll():void
Locks all questions.
MatchingPlayer
  
Locks all questions that have been correctly evaluated.
MatchingPlayer
  
questionAt(index:Number):String
Returns the persisted property name of the question at index.
MatchingPlayer
  
questionValueAt(index:Number, defaultValue:*):*
Returns the persisted property value of the question at index.
MatchingPlayer
  
Resets the selected and evaluated response properties for each question that has been evaulated and is not correct.
MatchingPlayer
  
resetResponseAt(questionIndex:Number):void
Resets the selected and evaluated reponse for the question at questionIndex.
MatchingPlayer
  
Resets the selected and evaluated response properties for each question.
MatchingPlayer
  
[static] Removes all properties set by the player.
MatchingPlayer
  
responseAt(index:Number):String
Returns the persisted property name of the response at index.
MatchingPlayer
  
responseValueAt(index:Number, defaultValue:*):*
Returns the persisted property value of the response at index.
MatchingPlayer
  
selectQuestionAt(index:Number):void
Selects the question at index.
MatchingPlayer
  
selectResponseAt(index:Number):void
Selects the response at index for the currently selected question.
MatchingPlayer
  
setQuestionLockAt(index:Number, locked:Boolean):void
Sets or clears the lock for the question at index.
MatchingPlayer
  
setStoryboardState(sb:Storyboard, state:String):void
[static] Modifies the storyboard to match the described state passed.
MatchingPlayer
  
unlockAll():void
Unlocks all questions.
MatchingPlayer
Protected Methods
 MethodDefined By
  
[override] Initializes the storyboard.
MatchingPlayer
  
[override] Loads the storyboard.
MatchingPlayer
  
[override] Removes known completion criteria from the CompleteRemaining storyboard persisted property.
MatchingPlayer
 Inherited
Performs cleanup actions when a storyboard is unloaded.
BasePlayer
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
 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 evaluate() method is invoked.MatchingPlayer
  Dispatched when a selection is changed, or when the storyboard is first loaded.MatchingPlayer
 InheritedDispatched before a storyboard is unloaded.BasePlayer
Property Detail
correctproperty
correct:Boolean  [read-only]

true if all questions have been correctly evaulated, false else. If the storyboard property value is null, false is returned.

This method returns the value of the current storyboard's Correct persisted property.


Implementation
    public function get correct():Boolean
extendedDistractorsproperty 
extendedDistractors:Boolean

Specifies how the class should handle selection of invalid question and response indices.

If this property value is true, the MatchingPlayer will treat non-empty questions with an empty answer and non-empty answers with an empty question as additional distractors.

The default value is false.


Implementation
    public function get extendedDistractors():Boolean
    public function set extendedDistractors(value:Boolean):void
isPracticeQuestionproperty 
isPracticeQuestion:Boolean  [read-only]

true if the question is marked as a practice question, false else. If the storyboard property value is null, true is returned.

This method returns the value of the current storyboard's IsPracticeQuestion persisted property.


Implementation
    public function get isPracticeQuestion():Boolean
maximumDistractorsproperty 
maximumDistractors:int

Indicates the maximum number of distractors to be processed.

Note that if this value is 1, the only distractor property processed will be "Distractor". If this value is greater than 1, the player will process properties named "Distractor[n-1]" where [n] is a number between 1 and maximumDistractors.

The default value is 1.


Implementation
    public static function get maximumDistractors():int
    public static function set maximumDistractors(value:int):void
maximumQuestionsproperty 
maximumQuestions:int

Indicates the maximum number of question/answer pairs to be processed.

The default value is 5.


Implementation
    public static function get maximumQuestions():int
    public static function set maximumQuestions(value:int):void
resetEvaluationOnSelectionproperty 
resetEvaluationOnSelection:Boolean

Specifies how the class should handle selection of previously evaulated questions.

If this property value is true, when a new response is selected for a question that already has an evaulated response, the evaluated response is no longer associated with the question. If this property value is false, no action is taken.

The default value is true.


Implementation
    public function get resetEvaluationOnSelection():Boolean
    public function set resetEvaluationOnSelection(value:Boolean):void
selectedQuestionIndexproperty 
selectedQuestionIndex:Number  [read-only]

The index of the currently selected question. If the storyboard property value is null, -1 is returned. If no question has been selected, 0 is returned.

This method returns the value of the current storyboard's SelectedQuestionIndex persisted property.


Implementation
    public function get selectedQuestionIndex():Number
selectionsCompleteproperty 
selectionsComplete:Boolean  [read-only]

true if all questions that have not yet been evaluated have a selected response and at least one question has not yet been evaluated; false else. If the storyboard property value is null, false is returned.

This method returns the value of the current storyboard's SelectionsComplete persisted property.


Implementation
    public function get selectionsComplete():Boolean
statusproperty 
status:String  [read-only]

The aggregate status of the questions in the current storyboard. If the storyboard property value is null, the empty string ("") is returned. This value will be one of the QuestionStatusTypes constant values.

This method returns the value of the current storyboard's Status persisted property.


Implementation
    public function get status():String

See also

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 MatchingSelectionEvent.SELECTION_CHANGE event is dispatched.
  5. The StoryboardEvent.LOAD_COMPLETE event is dispatched.
  6. The checkForComplete() method is invoked. If all completion criteria have been met, the StoryboardEvent.COMPLETE event is dispatched.


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

See also

strictSelectionproperty 
strictSelection:Boolean

Specifies how the class should handle selection of invalid question and response indices.

If this property value is true, invoking the selectQuestionAt() or selectResponseAt() methods causes the player to examine the value of the question or response at the passed index prior to selection. If the index paramter is invalid, or the question or response at index is null, the empty string (""), or an AssetData object whose filename member value is null or the empty string, no action is taken. If this property value is false, no additional checks are performed.

The default value is true.


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

See also

totalQuestionsproperty 
totalQuestions:Number  [read-only]

The total number of valid questions in the current storyboard. If the storyboard property value is null, -1 is returned.

This method returns the value of the current storyboard's TotalQuestions persisted property.


Implementation
    public function get totalQuestions():Number
totalResponsesproperty 
totalResponses:Number  [read-only]

The total number of valid responses in the current storyboard. If the storyboard property value is null, -1 is returned.

This method returns the value of the current storyboard's TotalResponses persisted property.


Implementation
    public function get totalResponses():Number
Constructor Detail
MatchingPlayer()Constructor
public function MatchingPlayer()

Creates a new instance of the MatchingPlayer.

Method Detail
detailsOfQuestionAt()method
public function detailsOfQuestionAt(index:Number):MatchingQuestionDetails

Returns detailed information about the question at index. If no question can be found at index, the returned object will contain default values.

Parameters

index:Number — The index of the question to return detailed information for.

Returns
MatchingQuestionDetails — A MatchingQuestionDetails object containing detailed information for the question at index.

See also

detailsOfResponseAt()method 
public function detailsOfResponseAt(index:Number):MatchingResponseDetails

Returns detailed information about the response at index. If no response can be found at index, the returned object will contain default values.

Parameters

index:Number — The index of the response to return detailed information for.

Returns
MatchingResponseDetails — A MatchingResponseDetails object containing detailed information for the response at index.

See also

evaluate()method 
public function evaluate():void

Evaluates the selected responses.

Invoking this method causes the selected response index associated with each question to be cleared, and the evaluated response index associated with each question to be set to the selected response index, assuming the question had a non-zero selected reponse index value. The Question[n]Correct storyboard persisted property is set to true if the evaluated response index of each question matches the question's answer. Summary information is updated, and a MatchingEvaluateEvent.EVALUATE event is dispatched. If the selectedQuestionIndex property value is greater than 0, it is reset to 0 (indicating no question is selected), and the player dispatches a MatchingSelectionEvent.SELECTION_CHANGE event.

See also

getStoryboardState()method 
public static function getStoryboardState(sb:Storyboard):String

Creates a string describing the state of the storyboard.

This method returns a multiple-character string to describe the state of the storyboard. The size of the string will depend on the number of question/answer pairs and distractors, as well as the aggregate state. Index data, selected/evaluated response data, and scoring data are all included (or can be recreated from) the state string. Lock information is not included. The returned string may contain upper- and lower-case letters, numbers, and the dot (.) character.

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.

See also

getSummary()method 
public function getSummary():MatchingSummary

Returns a MatchingSummary object containing aggregate information about the storyboard.

Returns
MatchingSummary — A MatchingSummary object containing aggregate information about the storyboard.

See also

indexOf()method 
public function indexOf(propertyName:String):Number

Returns the index of the propertyName. If the storyboard property value is null, -1 is returned. If propertyName is null or the empty string (""), 0 is returned. If no index value can be found for propertyName, -1 is returned.

This method returns the value of the current storyboard's [propertyName]Index persisted property.

Parameters

propertyName:String — The property name to return the index of.

Returns
Number — The index of propertyName.
initializeStoryboard()method 
override protected function initializeStoryboard():void

Initializes the storyboard.

This method is invoked by the storyboard property set method when a non-null storyboard object is loaded and its Initialized persisted property value is false. The storyboard property set method will dispatch the initialized event after invoking this method.

The MatchingPlayer initializes a storyboard by performing the following actions:

See also

isQuestionAtLocked()method 
public function isQuestionAtLocked(index:Number):Boolean

Identifies whether the question at index is locked.

A locked question cannot be selected. If the storyboard property value is null, this method returns true. This method uses the current storyboard's Question[n]Locked persisted property.

Parameters

index:Number — The index of the question to retrieve the lock status of.

Returns
Booleantrue if the question is locked, false else.

See also

isResponseAtLocked()method 
public function isResponseAtLocked(index:Number):Boolean

Identifies whether the response at index is locked.

A response is considered locked if the index of the response matches the selected response index or the evaluated response index of a question that is locked. If the storyboard property value is null, this method returns true. If no question can be found with a selected or evaluated response index matching index, this method returns false.

Parameters

index:Number — The index of the response to retrieve the lock status of.

Returns
Booleantrue if the response is locked, false else.

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 MatchingPlayer performs the following actions:

See also

lockAll()method 
public function lockAll():void

Locks all questions.

See also

lockCorrect()method 
public function lockCorrect():void

Locks all questions that have been correctly evaluated.

See also

questionAt()method 
public function questionAt(index:Number):String

Returns the persisted property name of the question at index. If the storyboard property value is null, index is less than 1, or no question property can be found at index, the empty string (quot;quot;) is returned.

The return value (if not the empty string) will be of the form "Question[n]", where [n] is a value between 1 and MatchingPlayer.maximumQuestions. This method uses the [Question[n]]Index persisted property value of the current storyboard.

Parameters

index:Number — The index to retrieve the question's persisted property name of.

Returns
String — The property name of the question at index.
questionValueAt()method 
public function questionValueAt(index:Number, defaultValue:*):*

Returns the persisted property value of the question at index. If the storyboard property value is null, index is less than 1, or no question property can be found at index, the defaultValue is returned.

This method uses the [Question[n]]Index persisted property value of the current storyboard.

Parameters

index:Number — The index to retrieve the question's persisted property value of.
 
defaultValue:* — A default value to return if the property at index cannot be found.

Returns
* — The property value of the question at index, or defaultValue.
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 MatchingPlayer will remove the following substrings from the completeRemaining persisted property:

SubstringMeaning
answerCorrect;The value of the correct property is true.
answerEvaluated;All questions have an evaluated response.

See also

resetIncorrectResponses()method 
public function resetIncorrectResponses():void

Resets the selected and evaluated response properties for each question that has been evaulated and is not correct.

This method performs the same functions as the resetResponseAt() method for each question whose [Question[n]]Correct persisted property value is false. If any properties are removed, the player will dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

See also

resetResponseAt()method 
public function resetResponseAt(questionIndex:Number):void

Resets the selected and evaluated reponse for the question at questionIndex.

If questionIndex does not reference a valid question, invoking this method has no effect. This method removes the current storyboard's [Question[n]]SelectedResponseIndex, [Question[n]]EvaluatedResponseIndex, and [Question[n]]Correct persisted property values, if present. Summary information is updated, and if any of the above properties are removed, the player will dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

Parameters

questionIndex:Number — The index of the question to reset the responses of.

See also

resetResponses()method 
public function resetResponses():void

Resets the selected and evaluated response properties for each question.

This method removes the the current storyboard's [Question[n]]SelectedResponseIndex, [Question[n]]EvaluatedResponseIndex, and [Question[n]]Correct persisted property values, if present. Summary information is updated, and if any of the above properties are removed, the player will dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

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:

  • Initialized
  • CompleteRemaining
  • Complete
  • NarrationComplete
  • The Complete property of each ChildElement object in the storyboard's Commands ChildElementCollection property, if it exists.
  • DistractorValid
  • DistractorIndex (if the ResponseIndexesGenerated persisted property value was true)
  • TotalQuestions
  • TotalResponses
  • QuestionIndexesGenerated
  • ResponseIndexesGenerated
  • TotalSelected
  • TotalEvaluated
  • TotalCorrect
  • TotalIncorrect
  • Correct
  • Status
  • SelectionsComplete
  • SelectedQuestionIndex

For values of [n] between 1 and MatchingPlayer.maximumQuestions, the following properties will be removed:

  • Question[n]Valid
  • Question[n]Index (if the QuestionIndexesGenerated persisted property value was true)
  • Question[n]SelectedResponseIndex
  • Question[n]EvaluatedResponseIndex
  • Question[n]Correct
  • Question[n]Locked
  • Answer[n]Valid
  • Answer[n]Index (if the ResponseIndexesGenerated persisted property value was true)

For values of [n] between 2 and MatchingPlayer.maximumDistractors, the following properties will be removed:

  • Distractor[n-1]Valid
  • Distractor[n-1]Index (if the ResponseIndexesGenerated persisted property value was false)

See also

responseAt()method 
public function responseAt(index:Number):String

Returns the persisted property name of the response at index. If the storyboard property value is null, index is less than 1, or no response property can be found at index, the empty string (quot;quot;) is returned.

The return value (if not the empty string) will be of the form "Answer[n]", where [n] is a value between 1 and MatchingPlayer.maximumQuestions, "Distractor", or "Distractor[n]" where [n] is a value between 1 and MatchingPlayer.maximumDistractors - 1. This method uses the [Answer[n]]Index and DistractorIndex persisted property values of the current storyboard.

Parameters

index:Number — The index to retrieve the response's persisted property name of.

Returns
String — The property name of the response at index.
responseValueAt()method 
public function responseValueAt(index:Number, defaultValue:*):*

Returns the persisted property value of the response at index. If the storyboard property value is null, index is less than 1, or no response property can be found at index, the defaultValue is returned.

This method uses the [Answer[n]]Index and DistractorIndex persisted property values of the current storyboard.

Parameters

index:Number — The index to retrieve the response's persisted property value of.
 
defaultValue:* — A default value to return if the property at index cannot be found.

Returns
* — The property value of the response at index, or defaultValue.
selectQuestionAt()method 
public function selectQuestionAt(index:Number):void

Selects the question at index.

Only one question can be selected at a time. Invoking this method will cause the currently selected question to be unselected. Passing a value of 0 for index will unselect all questions.

If the question at index is locked, the storyboard property value is null, or the strictSelection property value is true and the question at index does not exist or is empty, invoking this method has no effect.

Invoking this method sets the current storyboard's SelectedQuestionIndex persisted property value to index, and causes the player to update the summary information for the storyboard and to dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

Parameters

index:Number — The index of the question to select.

See also

selectResponseAt()method 
public function selectResponseAt(index:Number):void

Selects the response at index for the currently selected question.

If no question is selected, the response at index is locked, the selected question is locked, the storyboard property value is null, or the strictSelection property value is true and the response at index does not exist or is empty, invoking this method has no effect.

Invoking this method will remove the previously selected response from the selected question. The selected response will also be removed from any questions (other than the currently selected question) that identify the reponse as their selected response or evaulated response. This may result in the aggregate status and/or scoring information to be changed.

Once the response is associated with the selected question, the current storyboard's SelectedQuestionIndex persisted property is set to 0 (indicating no selection), and the current storyboard's [Question[n]]SelectedResponseIndex persisted property is set to index. The player will also dispatch a MatchingSelectionEvent.SELECTION_CHANGE event.

Parameters

index:Number — The index of the response to select for the currently selected question.

See also

setQuestionLockAt()method 
public function setQuestionLockAt(index:Number, locked:Boolean):void

Sets or clears the lock for the question at index.

If the storyboard property value is null, or no question can be found at index, invoking this method has no effect.

This method returns the value of the current storyboard's Question[n]Locked persisted property.

Parameters

index:Number — The index of the question to set or clear the lock of.
 
locked:Boolean — The lock state to set.

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 indicates 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.

See also

unlockAll()method 
public function unlockAll():void

Unlocks all questions.

See also

Event Detail
matchingEvaluate Event
Event Object Type: impression.events.MatchingEvaluateEvent
MatchingEvaluateEvent.type property = impression.events.MatchingEvaluateEvent.EVALUATE

Dispatched when the evaluate() method is invoked.

The MatchingEvaluateEvent.EVALUATE constant defines the value of the type property of a matching evaluate 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.
statusA QuestionStatusTypes enumeration describing the current status of the storyboard.
correctIndicates whether or not all question/answer pairs were correctly evaluated.
totalCorrectThe number of valid questions evaluated as correct.
totalIncorrectThe number of valid questions evaluated as incorrect.

See also

matchingSelectionChange Event  
Event Object Type: impression.events.MatchingSelectionEvent
MatchingSelectionEvent.type property = impression.events.MatchingSelectionEvent.SELECTION_CHANGE

Dispatched when a selection is changed, or when the storyboard is first loaded.

The MatchingSelectionEvent.SELECTION_CHANGE constant defines the value of the type property of a matching selection 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.
questionIndexThe index of the selected question.
responseIndexThe index of the selected response.
selectionsCompleteIndicates whether or not all valid questions have a selected response.

See also