I am using an ActionScript 2.0 for my project. I have a movie clip that is moving along the x-axis. My problem is, if that movie clip reaches the given boundary, it should automatically deduct one life. My codes doesn't work.
Here's my code for the timeline:
var life:Number = 5;
lives = 3;
boundary = 280;
var speed:Number = 1;
var boundary:Number = 280;
this.onEnterFrame = function():Void {
if (clip._x > boundary) {
clip._x -= speed;
} else {
clip._x = boundary;
delete this.onEnterFrame;
}
}
if(lives == 0){
gotoandstop(132);
}
Here's my code for moving mc:
onClipEvent (load) {
speed = 1;
boundary = 280;
}
onClipEvent (enterFrame) {
if (this._x > boundary) {
this._x -= speed;
}
else {
this._x = boundary;
this._visible = false;
life -= 1;
lifebox.text = life.toString();
}
}
First, you don't need to have a code for the timeline and a code for your movie clip.
On the other hand, if you want your movie clip to disappear, you should remove it or put it elsewhere, because the hitTest will run continuously.
Main timeline code