Hey Ben whats happening here is that flash runs code in order so its going to the "_over" label and then going to the "_down" state instantly after that. IE its trying to do the "over" but your command tells it to do the "down" before the you actually have time to see the effect of the first command.
So you can do what you need with a variable and a few if statements
btnHit3DModelling_mc.onRelease= function(){
if(this.s == "start" || this.s == undefined){
btn3DModelling_mc.gotoAndPlay("_over");
this.s = "over";
}
if(this.s == "over"){
btn3DModelling_mc.gotoAndPlay("_down");
this.s = "start";
}
}
- btnHit3DModelling_mc.onRelease= function(){
- if(this.s == "start" || this.s == undefined){
- btn3DModelling_mc.gotoAndPlay("_over");
- this.s = "over";
- }
- if(this.s == "over"){
- btn3DModelling_mc.gotoAndPlay("_down");
- this.s = "start";
- }
- }
So whats going on here is the first statement checks to see if the variable "s" is equal to start or if its undefined (this is the very first state when the button has never been pressed because we didn't set "s" to be anything)
If the "s" is equal one then flash plays the "over" animation and sets the variable "s" to equal over
Then if the button is pressed again the first statement won't fire because "s" is not equal to either start or undefined. However, it will play the second statement because "s" is now equal "over"
At the end of the over statement we reset "s" to equal "start" so the first part runs again on the 3rd btn press
Now there's a catch here. If you press the button twice quickly the animation will go to the second state right away since the system isn't checking to see if the action has finished. You can solve this a few different ways. You can write script to set "s" only after the timeline has gotten to a specific point or you can test if "s" is equal to over AND the current frame of the animation is equal to the last frame of the "over" section.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com