home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.geom
- {
- public class Counter
- {
- private var iStart:Number;
-
- public var speed:Number;
-
- public var end:Number;
-
- private var iSpeed:Number;
-
- private var back:Boolean;
-
- public var start:Number;
-
- private var loop:Boolean;
-
- public var value:Number;
-
- private var iEnd:Number;
-
- private var firstCount:Boolean = true;
-
- public function Counter(start:Number, end:Number, speed:Number, loop:Boolean = true, back:Boolean = true)
- {
- super();
- this.loop = loop;
- this.back = back;
- this.setCounter(start,end,speed);
- }
-
- public function get floorValue() : Number
- {
- return Math.floor(this.value);
- }
-
- public function update() : Number
- {
- this.value += this.speed;
- if(this.value > this.end)
- {
- this.value = this.start;
- }
- return this.value;
- }
-
- public function reset() : void
- {
- this.start = this.iStart;
- this.end = this.iEnd;
- this.speed = this.iSpeed;
- this.value = this.start;
- this.firstCount = true;
- }
-
- public function count(firstCheck:Boolean = true) : Number
- {
- if(this.firstCount && firstCheck)
- {
- this.firstCount = false;
- }
- else
- {
- this.update();
- }
- return this.value;
- }
-
- public function setCounter(start:Number, end:Number, speed:Number) : void
- {
- this.start = this.iStart = start;
- this.end = this.iEnd = end;
- this.speed = this.iSpeed = speed;
- this.value = start;
- }
- }
- }
-
-