var currStam:int = 100;
var maxStam:int = 100;
var stamBar:MovieClip = new staminaBar();
stamBar.gotoAndStop(Math.floor(currStam/maxStam)+1);
//while running button is pressed
switch(true){
case currStam >0: currStam -= 1; stamBar.gotoAndStop(Math.floor(currStam/maxStam)+1); charRun(); break;
default: currStam = 0; break;
}
//after sex
currStam = maxStam;
stamBar.gotoAndStop(Math.floor(currStam/maxStam)+1);
package
{
import flash.display.Shape;
import flash.geom.ColorTransform;
public class ProgressBar extends Shape
{
private var colors:Array=[0x99DC57, 0xF38230, 0xF33E30];
public function ProgressBar(barWidth:int, barHeight:int)
{
this.graphics.beginFill(colors[0], 1);
this.graphics.drawRect(0,0,barWidth, barHeight);
this.graphics.endFill();
}
public function updateProgressBar(stamina:int):void{
var my_color:ColorTransform = new ColorTransform();
if(stamina > 80){
my_color.color = colors[0];
} else if(stamina > 30) {
my_color.color = colors[1];
} else {
my_color.color = colors[2];
}
this.scaleX = stamina/100;
this.transform.colorTransform = my_color;
my_color = null;
}
public function dispose():void{
}
}
}
var progressbar:ProgressBar = new ProgressBar(150, 20);
addChild(progressbar);
progressbar.updateProgressBar(90);
Users browsing this forum: No registered users