topical media & game development

talk show tell print

actionscript-misc-TextTo300_TimerVersion.ax

actionscript-misc-TextTo300_TimerVersion.ax [swf] flex


  package {
    import flash.display.*;
    import flash.events.*;  
    import flash.utils.*;
    import flash.text.*;  
    
    public class @ax-actionscript-misc-TextTo300_TimerVersion extends TextField {
      private var timer:Timer;
      
      public function @ax-actionscript-misc-TextTo300_TimerVersion () {
        timer = new Timer(50, 0);
        timer.addEventListener(TimerEvent.TIMER, moveTextRight);
      }
  
      public function moveTextRight (e:Event):void {
        if (x <= 300) {
          x += 10;
          if (x > 300) {
            x = 300;
          }
        } else {
          stop();
        }
      }
  
      public function start ():void {
        // Start playing the animation
        timer.start();
      }
  
      public function stop ():void {
        // Pause the animation
        timer.stop();
      }
    }
  }
  


(C) Æliens 27/08/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.