(...) startButton.addEventListener(MouseEvent.CLICK, startButtonClicked); (...) private function startButtonClicked(e:MouseEvent):void{ if (!playingFlag) return; // prevents queuing playingFlag = true; // setting auxiliary variable m_esquimo.Start(); }
MOUSE_OVER / MOUSE_OUT events are queued. It is associated to Esquimo engine structure. In practice if you call m_esquimo.Start() method 3 times in a row you would have to call 3 times m_esquimo.Stop() method in order to stop the animation. In some circumstances such behaviour may be useful. However if the queuing is needless, you can easily eliminate it by adding animation state tracking using auxiliary variable. In the above example : playingFlag : Boolean .
(...) stopButton.addEventListener(MouseEvent.CLICK, stopButtonClicked); (...) private function stopButtonClicked(e:MouseEvent):void{ if (!playingFlag) return; // prevents queuing playingFlag = false; // setting auxiliary variable m_esquimo.Stop(); }
private function frameRendHandler(e:Event) { actualFrameLabel.text = String(m_esquimo.GetFrame()); }
In our example the method is called each time a frame of Esquimo SWF is rendered. The frameRendHandler function is a response to FRAME_RENDERED event about which you can read more above. In this case taken value is saved in the text box prepared before.
(...) numericStepper1.maximum = m_esquimo.GetTotalFrames(); (...)
In our example taken value is being used as upper limit of used NumericStepper.
In order to call the method the playing of Esquimo SWF animation must be stopped first. In our example, NumericStepper, thanks to which you can enter the current frame number, is visible only after pressing “Stop” button (what calls Stop() method). The setting of the current frame itself doesn’t cause any visible changes on the screen. In order to display new current frame of animation, you need to call RenderSingleFrame() method additionally.
The exemplary piece of code shown below is responsible for a jump to appropriate frame of the animation after the change of the value in numericStepper1 – a response to .CHANGE event.
(...) numericStepper1.addEventListener(Event.CHANGE, numericStepperOnChange); (...) private function numericStepperOnChange(e:Event) { m_esquimo.SetFrame(e.target.value); m_esquimo.RenderSingleFrame(); }
The method is used after prior call of SetFrame(frame:int) – see the description above. RenderSingleFrame together with SetFrame may be used for reverse playing of Esquimo SWF animation, playing with variable speed, looping parts of animation, generally for navigation along internal time axis using AS3.
(...) m_esquimo.SetFrame(targetframe); m_esquimo.RenderSingleFrame(); (...)