draws a single line with a random stroke style every 250 milliseconds. It uses clear( ) to erase the previously drawn line. : Timer : Animation Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Animation » Timer »

 

draws a single line with a random stroke style every 250 milliseconds. It uses clear( ) to erase the previously drawn line.


 
package {
  import flash.display.*;
  import flash.utils.*;
  import flash.events.*;

  public class Main extends Sprite {

    private var s:Shape;

    public function Main(  ) {
      s = new Shape(  );
      addChild(s);

      var t:Timer = new Timer(250);
      t.addEventListener(TimerEvent.TIMER, timerListener);
      t.start(  );
    }

    private function timerListener (e:TimerEvent):void {
      s.graphics.clear(  );
      s.graphics.lineStyle(random(110), random(00xFFFFFF));
      s.graphics.moveTo(random(0550), random(0400));
      s.graphics.lineTo(random(0550), random(0400));
    }

    public function random (minVal:int, maxVal:int):int {
      return minVal + Math.floor(Math.random(  ) (maxVal + - minVal));
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Animation
» Timer