0
votes

I am using an actionscript 2.0, and i have a movieclips that are are running along the x-axis and given each of them a boundary. And i have also a movieclip for my gamelives. If the three movieclips reaches to its given boundary, the 3lives will turn into 0 and should proceed to the next frame. My problem is, the codes for my gotoandstop doesn't work.

Here is my code for movie clip:

onClipEvent (load) {
speed = 5;
boundary = 280;     
}
onClipEvent (enterFrame) {
if (this._x > boundary) {
    this._x -= speed;       
} 
else {
    this._x = boundary;
    _parent.life -= 1;
    _parent.lifebox.text = _parent.life;

    this.swapDepths(0);
    this.removeMovieClip();
    delete this.onEnterFrame;

}
}

Here's my code for my timeline:

stop();
var keyListener:Object = new Object();
var life:Number = 3;

keyListener.onKeyDown = function() {


if (textbox.text == "ant"){
ant_mc.swapDepths(0);
ant_mc.removeMovieClip();
bee_mc._x +=40;
bug_mc._x +=40;

}

if(life == 0){
gotoandstop(1);
}

if (Key.isDown(Key.ENTER)) {
textbox.text="";

}

};
1
Why do you use var life:Number = 3; instead of var life = 3; Also, instead of putting those variables in the timeline, I would make an offscreen object to hold those numbers and control the frame movement. (Reference to it using _root from your movieclip class)Aify
all of my codes are working except in the condition if(life == 0){gotoandstop(1);} to proceed to the next frame.nesty santayo

1 Answers

0
votes

Try moving the check from the timeline to the onEnterFrame(). The way I see it, the check is only run if a key is down, so you'll never check it. I think you need to be checking if life == 0 every frame.