If and else if action script help please

im a bit confused and stuck, im trying to make this movie clip (presenter1) to play all is animations at the right times

when it starts the movie clip should be on the frame label **rock which is frame 1 **then on rollover it should go to frame label gesture which is frame 2 onRelease it should go to frame label **walk which is frame 3 **then if its already on the walk frame then go to walkback which is frame 4

any help where im going wrong?

what im trying to go for is somthing like this

http://cars.com/waitingroom/


presenter1.onRollOver = function () {
 if (frame = "walk") {
  stop(); }
 else if (frame = "rock") { 
  this.gotoAndPlay(2);
}
}
presenter1.onRollOut = function () {
 if (frame = "walk") {
  stop(); }
 else if (frame = "rock") { 
  this.gotoAndPlay(1);
} 
}
presenter1.onRelease = function () {
 if (frame = "rock") {
  this.gotoAndPlay(3); }
 else if (frame == "walk") { 
  this.gotoAndPlay(4);
}
}

wrong: (frame = “walk”)
right: (frame == “walk”)

[quote=glosrfc;2356787]wrong: (frame = “walk”)
right: (frame == “walk”)[/quote]

ah getting there now,

i think there must be something wrong in the last part becuase onrelease jumps straight to the walkback and if you roll out on that state it jumps straight back to rock

as you can see

http://www.nwmsltd.com/rock.html

im so close now it all work apart from it doesnt goto gesture (frame 2) once its done it once

presenter1.onRollOver = function () {
 if (frame == "walk") {
  stop(); }
 else if (frame = "rock") 
 this.gotoAndPlay(2);
}
presenter1.onRollOut = function () {
 if (frame == "gesture") {
  this.gotoAndStop(1); } 
 else if (frame = "walk", "walkback") { 
  stop(); }
}

presenter1.onRelease = function () { 
 if (frame = "rock") { 
  this.gotoAndPlay(3); } 
 else if (frame == "walk") { 
  this.gotoAndPlay(4); 
} 
} 

www.nwmsltd.com/rock.html every thing works fine but once you have rollover it once it never jumps up again?

timeline coding is full of this problem

I highly suspect you are tell a variable to be something and moving the timeline, this causes “frame” to become undefined.

I think you are not telling it to go back to “walk” when you finish the jump bit

hmm ok well i have just uploaded my source file to see if that helps, as im just a bit confused why its not doing it?

www.nwmsltd.com/rock.fla

I’ve got it sort of working…

I’ve swapped the “check frame” for “check var”

Where, exactly, are you defining what frame is? I see that you have frame labels called walk, rock, gesture and walkback but that’s completely different from have a variable called frame.

You can either assign a value to the variable “frame” according to which particular label you’re at in presenter1, e.g. frame = “rock”, frame = "walk"
or by using (if _currentframe == frame_number) in the AS in your root layer.

You can’t actually reference a frame label directly in AS1 or 2.

Edit: I see that randomagain has adopted the first approach! :slight_smile:

thanks for that guys think thats got it working, now im just a bit stumped how i can do this next part, as the MCs are on the same frame on the timeline the white box that fades up doesnt hide the over presenter what can i do?

i want them all to be visable at the start but when one of them walks forward i want the the other to either fade away and once you click again it goes to walkback and the others fade back?
www.nwmsltd.com/rock.html is what it looks like now

Thanks again

flash has an inbuilt tween class, you can get the ones you haven’t clicked to alpha fade out.

for(i=0;i<10;i++){
if(clickedVar != i){
tw1.tween(["but"+i], "_alpha", 100,0,1,true)
}
}