Events - TeachMeInc/MathGames-SDK GitHub Wiki


General Overview
MathGames Methods
Events
Using QuestionPanel

The MathGames class implements EventDispatcher and fires events when important things happen. Any event object dispatched by MathGames will be of type MathGamesEvent. The MathGamesEvent class contains an instance variables called data which is used by some events to return some extra information about what happened.

MathGamesEvent.ERROR

This event is fired whenever an error occurs at any time during the use of the MathGames SDK. The data variable will be of type String and contain an error message describing what exactly went wrong.

MathGamesEvent.CONNECTED

This event is fired when the MathGames Flash SDK successfully connects to the remote service. The data variable is null for this event.

MathGamesEvent.SKILL_SELECTED

This event is fired once a player has successfully selected a skill using the Skill Select panel and is ready to start receiving question data. The data variable is null for this event.

MathGamesEvent.SKILL_SELECT_CANCELLED

This event is fired if the user closes the Skill Select panel without selecting a skill. The data variable is null for this event.

MathGamesEvent.SESSION_READY

This event is fired after MathGames.instance.startSession is invoked, once the questions are ready and gameplay can begin. The data variable is null for this event.

MathGamesEvent.QUESTION_READY

This event is fired during a play session when a question is ready to be displayed to the player. It will generally happen immediately after a SESSION_READY event, or after invoking the question answer continuation/callback provided by the previous question. The data variable has type com.mathgames.api.local.Question and contains the BitmapData required to render the question and answers. It also provides a the index of the correct answer, as well as a callback to invoke when the player has selected an answer.

MathGamesEvent.AVERAGE_TIME_CHANGE

This event is fired whenever the average time per question changes. This happens usually when the type of question presented by the SDK changes. The data variable has type int and represents the number of milliseconds the average player will take to answer the questions in the current set.

MathGamesEvent.PROGRESS_CLOSED

This event is fired after MathGames.instance.showProgress is invoked, once the panel has been dismissed and the player want to continue their play session. The data variable is null for this event.