Limited character flight with actionscript

Hi all, i am creating a flash project that uses a character with limited flight. the idea is that the character has a set amount of time that they can fly for, say 3 seconds and then they run out of power and the power will recharge once they let go of the button but will re-charge at a slower rate than used but i have run into trouble. if anyone can point me in the right direction that would be great. here is my code

var yspeed = 0;
var xspeed = 0;
var gravity = 0.6;
var rotationspeed = 0;
var power = 1.6;
var flightPower = 1.6;
var friction = 0.9;
var flightTime = 3;
var curFlightTime= 3;
onEnterFrame = function() {
yspeed += gravity;
xspeed = friction;
this._x += xspeed;
rotationspeed = friction;
this._rotation = 0+rotationspeed;
if (this._y<=400-this._height/2) {
this._y += yspeed;
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
rotationspeed += power
xspeed/2;
} else if (Key.isDown(Key.RIGHT)) {
xspeed += power;
rotationspeed += power
xspeed/2;
}
} else {
xspeed *= friction;
yspeed = 0;
this._y = 400-this._height/2;
}

[COLOR=Purple]//trouble starts here[/COLOR]
if (Key.isDown(Key.UP)) {

yspeed -= flightPower;
curFlightTime=flightTime--;
countDown = function () {
     flightTime--;
     if (flightTime == 0) {
         flightPower = 0.2;
             }

}    
timer = setInterval(countDown, 500);

}else{
powerBack = function (){
flightTime = flightTime +0.1;
flightPower= 1.6;
if (flightTime >=3){
flightTime=3;
}
}
timer = setInterval(powerBack, 500)
}
[COLOR=Purple] //and ends here[/COLOR]
if (yspeed<0) {
yspeed *= friction;
}
}