home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / com / livebrush / geom / Counter.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  1.8 KB  |  80 lines

  1. package com.livebrush.geom
  2. {
  3.    public class Counter
  4.    {
  5.       private var iStart:Number;
  6.       
  7.       public var speed:Number;
  8.       
  9.       public var end:Number;
  10.       
  11.       private var iSpeed:Number;
  12.       
  13.       private var back:Boolean;
  14.       
  15.       public var start:Number;
  16.       
  17.       private var loop:Boolean;
  18.       
  19.       public var value:Number;
  20.       
  21.       private var iEnd:Number;
  22.       
  23.       private var firstCount:Boolean = true;
  24.       
  25.       public function Counter(start:Number, end:Number, speed:Number, loop:Boolean = true, back:Boolean = true)
  26.       {
  27.          super();
  28.          this.loop = loop;
  29.          this.back = back;
  30.          this.setCounter(start,end,speed);
  31.       }
  32.       
  33.       public function get floorValue() : Number
  34.       {
  35.          return Math.floor(this.value);
  36.       }
  37.       
  38.       public function update() : Number
  39.       {
  40.          this.value += this.speed;
  41.          if(this.value > this.end)
  42.          {
  43.             this.value = this.start;
  44.          }
  45.          return this.value;
  46.       }
  47.       
  48.       public function reset() : void
  49.       {
  50.          this.start = this.iStart;
  51.          this.end = this.iEnd;
  52.          this.speed = this.iSpeed;
  53.          this.value = this.start;
  54.          this.firstCount = true;
  55.       }
  56.       
  57.       public function count(firstCheck:Boolean = true) : Number
  58.       {
  59.          if(this.firstCount && firstCheck)
  60.          {
  61.             this.firstCount = false;
  62.          }
  63.          else
  64.          {
  65.             this.update();
  66.          }
  67.          return this.value;
  68.       }
  69.       
  70.       public function setCounter(start:Number, end:Number, speed:Number) : void
  71.       {
  72.          this.start = this.iStart = start;
  73.          this.end = this.iEnd = end;
  74.          this.speed = this.iSpeed = speed;
  75.          this.value = start;
  76.       }
  77.    }
  78. }
  79.  
  80.