# If and else if action script help please

**URL:** <https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679>\
**Category:** Uncategorized\
**Created:** [July 11, 2008, 9:03am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679 "2008-07-11T09:03:15Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [July 11, 2008, 9:03am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/1 "2008-07-11T09:03:15Z")

</div>

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/](http://cars.com/waitingroom/)

```auto

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);
}
}

```

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [July 11, 2008, 10:10am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/2 "2008-07-11T10:10:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [July 11, 2008, 10:33am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/3 "2008-07-11T10:33:18Z")

</div>

[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](http://www.nwmsltd.com/rock.html)

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [July 11, 2008, 2:05pm UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/4 "2008-07-11T14:05:33Z")

</div>

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

```auto
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](http://www.nwmsltd.com/rock.html) every thing works fine but once you have rollover it once it never jumps up again?

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 11, 2008, 2:22pm UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/5 "2008-07-11T14:22:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [July 11, 2008, 2:47pm UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/6 "2008-07-11T14:47:27Z")

</div>

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](http://www.nwmsltd.com/rock.fla)

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 11, 2008, 2:59pm UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/7 "2008-07-11T14:59:16Z")

</div>

I’ve got it sort of working…

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

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [July 11, 2008, 2:59pm UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/8 "2008-07-11T14:59:50Z")

</div>

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! 🙂

---

<div class="post-metadata">

**Author:** ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)\
**Post date:** [July 14, 2008, 9:52am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/9 "2008-07-14T09:52:28Z")

</div>

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](http://www.nwmsltd.com/rock.html) is what it looks like now

Thanks again

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [July 14, 2008, 10:29am UTC](https://forum.kirupa.com/t/if-and-else-if-action-script-help-please/265679/10 "2008-07-14T10:29:30Z")

</div>

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

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

```
