topical media & game development

talk show tell print

#graphic-flex-image-effects-07-source-aeon-AnimationComposite.ax

#graphic-flex-image-effects-07-source-aeon-AnimationComposite.ax [swf] [flash] flex


  package aeon {
  
          import aeon.events.AnimationEvent;
  
          public class @ax-graphic-flex-image-effects-07-source-aeon-AnimationComposite extends Animation {
          
                  private var _animationIndex:uint;
                  private var _animations:Array;
          
                  public function @ax-graphic-flex-image-effects-07-source-aeon-AnimationComposite(animations:Array) {
                          _animations = animations;
                  }
          
                  private function onEndAnimation(event:AnimationEvent):void {
                          if (++_animationIndex >= _animations.length) {
                                  stop();
                                  dispatchEvent(new AnimationEvent(AnimationEvent.END));
                          }
                  }
          
                  override public function stop():void {
                          super.stop();
                          for each (var animation:Animation in _animations) {
                                  animation.removeEventListener(AnimationEvent.END, onEndAnimation);
                                  if (animation.running) {
                                          animation.stop();
                                  }
                          }
                  }
          
                  override public function start():void {
                          _animationIndex = 0;
                          for each (var animation:Animation in _animations) {
                                  animation.addEventListener(AnimationEvent.END, onEndAnimation);
                                  animation.start();
                          }
                          super.start();
                  }
                          
                  override public function die():void {
                          super.die();
                          _animations = null;
                  }
  
                  public function get animations():Array {
                          return _animations;
                  }
                  
          }
          
  }


(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.