Improve this doc

Anim-listener

This sample demonstrates two ways to registering for callbacks from MOAIAnim.

MOAIAnim inherits MOAITimer, which itself inherits MOAIAction. This means that MOAIAnim emits both timer and action events.

In this sample we set up listeners for MOAIAction.EVENT_STOP, MOAITimer.EVENT_TIMER_LOOP and MOAITimer.EVENT_TIMER_KEYFRAME.

MOAIAction.EVENT_STOP is send when the action is stopped. In this case, the action is stopped automatically by MOAITimer, which has not been instructed to loop. When MOAITimer's time reaches the end of its span, the timer will automatically remove itself from the action tree.

MOAITimer.EVENT_TIMER_LOOP is called at the end of the timer's cycle. It is called whether or not a loop mode is enabled. It indicates that the timer as reached the end of its span and will either loop or roll over. In future versions of Moai the name of this event may be changed to clarify its meaning.

In addition to its built-in events, MOAITimer also provides a way to generate custom events at any point in time by using an anim curve and its key frames. When a MOAIAnimCurve is attached to a MOAITimer using setCurve (), the timer will emit an event each time a key frame is encountered. Typical uses for key frame events include checking for a button press at a specific time or playing a sound effect.