Jet pack game problems

hi i am trying to make a platform game where u walk around and kill things. i’ve made my char walk and i have found a code to make him fly except that i only want him to flay when he collects touches a certain object.
please help.
code or
fla would be most appreciated.
:slight_smile:

this is the code for my char mc to make him move.
onClipEvent (enterFrame) {
if(Key.isDown(Key.RIGHT)){
this._x += 12;
this.gotoAndStop (“right”);
}
else if(Key.isDown(Key.LEFT)){
this._x -= 12;
this.gotoAndStop (“left”);
}
else if(Key.isDown(Key.DOWN)){
this._x -= 0;
this.gotoAndStop (“down”);

}
}
and this is the code that goes on the frame to make him fly.

yspeed = 0;
xspeed = 0;
gravity = 0.2;
rotationspeed = 0;
power = 1;
friction = 0.9;
fly.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(37)) {
xspeed -= power;
rotationspeed += power
xspeed/2;
} else if (Key.isDown(39)) {
xspeed += power;
rotationspeed += power
xspeed/2;
}
} else {
xspeed *= friction;
yspeed = 0;
this._y = 400-this._height/2;
}
if (Key.isDown(38)) {
yspeed -= power;
}
if (yspeed<0) {
yspeed *= friction;
}
};

thanx