I made a game using Adobe Flash CC, Action Script 3.0. Please be patient and finish reading first! This is very urgent for me as it is for a school project. In the game it have a button and a vertical rectangle bar above the button. So this is how i want it to work: The yellow rectangle bar which is in another black rectangle bar rises and lowers, rises and lowers constantly, and part of the black bar is a green section, so the player have to press the button when the yellow bar reaches the green section, and the stick man in the stage will jump to the correct location. Otherwise jump to the ground and fail. whole game is 2D.
So i used the shape tween for the yellow bar, so it changes to a longer rectangle at the end of the frames. And i coded it to loop, how i loop it is like this, I coded the first frame like this :
var i = 0;
And the last frame like this:
if(i==0){

gotoAndPlay(642);
}
SO the whole tween repeats, so second frame the yellow bar rises a little and the third frame it rises a little too due to my shape tween. SO i code it like when the yellow bar rise to the green section, and you press the button, the stickman will do the animation in another scene to jump to the success spot, or else if you press the button when the yellow bar is in the black section, it goes to another scene whereby i created a animation of the stickman jumping to the floor and die.
For the frames which the yellow bar is in black section, the coding is:

jump.addEventListener(MouseEvent.CLICK , lsl9);

function lsl9 (event:MouseEvent):void{

gotoAndPlay(1, "Fail2");
}

Nothing wrong right? "jump" is my button instance name, "Fail 2" is my stickman jumping to floor scene. I changed the function of course for different scenes of the yellow bar at the black section.
Now, the coding when the yellow bar is at the green section is:

jump.addEventListener(MouseEvent.CLICK , lsl11);

function lsl11 (event:MouseEvent):void{
gotoAndPlay(1, "Success");
}

Here "Success" is the scene whereby the stick man jump to the correct spot.
So for example if it is six frames, 1st and 6th would be the one where I apply the loop code, 2nd to 4th would be the coding whereby the yellow bar reach black, 5th frame coding would be for the yellow bar reach green.
Let's call 1 action of the yellow bar going up "1 YU", so the first time the yellow bar goes up, before it reach 5th,when i press the button, it works perfectly, the stickman died by jumping to a wrong spot. And at the 5th frame, it succeeded by jumping to the correct spot when i press the button at 5th frame which is where the yellow bar is at the green section.
HOWEVER, when i don't press anything when the yellow bar goes up for 1 time, it goes up for a second time which is what i want but now, when i press the button when the yellow bar is at black section, the stickman performs the "Success" scene whereby he jump to the right spot.
It seems like my coding to loop my frames did loop my frame and the shape tween, but don't loop the actions applied on the individual frames, it just like carried the coding at the 5th frame which is the success frame forward to all frames in loop2. WHAT AM I DOING WRONG? SOMEONE PLEASE HELP ME!