Labs/Flash/ActionScript3/fl.motion.Animator

Adobe ActionScript 3.0 コンポーネントリファレンスガイド : Animatorクラスより

Animator クラスのメソッドを関数内で呼び出す場合、Animator インスタンスを関数の外部で宣言し、オブジェクトのスコープが関数内に限定されないようにします。
関数の内部でインスタンスを宣言すると、関数の最後に、 Flash Player の "ガベージコレクション" ルーチンによって Animator インスタンスが削除され、
ターゲットオブジェクトのアニメーションが無効になります。

org/ngsdev/test/AnimatorTest.as

package org.ngsdev.test {

  import flash.display.Sprite;
  import flash.display.MovieClip;
  import fl.motion.Animator;
  import fl.motion.MotionEvent;

  class AnimatorTest extends Sprite {

    var hoge_animator:Animator; //ここに宣言しないと動かない。
    var hoge_mc:MovieClip;

    public function AnimatorTest() {

      var hoge_animxml:XML = <Motion ....>....</Motion>;

      hoge_mc = new hoge();
      addChild(hoge_mc);

      hoge_animator = new Animator(hoge_xml, hoge_mc);

      //開始と終了をListen
      hoge_animator.addEventListener(MotionEvent.MOTION_START,_motionStart);
      hoge_animator.addEventListener(MotionEvent.MOTION_END,_motionEnd);

      hoge_animator.play();

    }

    private function _motionStart(e:Event) {
        trace(["start animation", name]);
    }

    private function _motionEnd(e:Event) {
        trace(["end animation", name]);
    }

  }

}