# Script to automatically play more then one movie clip

**URL:** <https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296>\
**Category:** flash\
**Created:** [June 24, 2008, 7:20pm UTC](https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296 "2008-06-24T19:20:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisribar](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@chrisribar](https://forum.kirupa.com/u/chrisribar)\
**Post date:** [June 24, 2008, 7:20pm UTC](https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296/1 "2008-06-24T19:20:06Z")

</div>

What I did so far can be seen at [www.chrisribar.com/serviceleads/](http://www.chrisribar.com/serviceleads/)

The problem I have is that it does turn the first button on when the movie starts. Due to this, it does not play the ‘out’ of the first slide. The script I used is:

currentButton = null;  
firstButtonPress = true;

function buttonCheck(n) {  
buttonCollection[‘b’+n].onRollOver = function(){  
this.gotoAndPlay(‘in’);   
};  
buttonCollection[‘b’+n].onRollOut = function(){  
this.gotoAndPlay(‘out’);  
};  
buttonCollection[‘b’+n].onPress = function(){  
this.gotoAndPlay(‘press’);  
this.enabled = false;  
buttonPressed(n);  
};  
}

function buttonPressed(n) {  
if (firstButtonPress == true) {  
mainClip.gotoAndPlay(“pageIn”+n);  
firstButtonPress = false;  
} else {  
buttonCollection[‘b’+currentButton].gotoAndPlay(‘out’);  
buttonCollection[‘b’+currentButton].enabled = true;  
mainClip.gotoAndPlay(“pageOut”+currentButton);  
}  
currentButton = n;  
}

for (z=0; z\<6; z++) {  
buttonCheck(z);  
}

In the mainClip movie clip, the last frame of the ‘Out’ plays this script:

gotoAndPlay(“pageIn”+\_parent.currentButton);

telling the clip to play the next ‘In’

If anyone could help I would greatly appreciate it. Thanks!

---

<div class="post-metadata">

**Author:** ![pantas](https://avatars.discourse-cdn.com/v4/letter/p/3e96dc/32.png) [@pantas](https://forum.kirupa.com/u/pantas)\
**Post date:** [June 25, 2008, 3:29pm UTC](https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296/2 "2008-06-25T15:29:44Z")

</div>

currentButton = null;  
firstButtonPress = true;

buttonCollection.b0.gotoAndPlay(“press”)  
buttonCollection.b0.enabled = false;  
buttonPressed(buttonCollection.b0);  
};

is this what you are looking for?  
.  
.  
.

---

<div class="post-metadata">

**Author:** ![chrisribar](https://avatars.discourse-cdn.com/v4/letter/c/5fc32e/32.png) [@chrisribar](https://forum.kirupa.com/u/chrisribar)\
**Post date:** [June 30, 2008, 1:36pm UTC](https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296/3 "2008-06-30T13:36:44Z")

</div>

it still doesn’t work…now the first button is permanetly disabled

---

<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:** [June 30, 2008, 2:25pm UTC](https://forum.kirupa.com/t/script-to-automatically-play-more-then-one-movie-clip/264296/4 "2008-06-30T14:25:41Z")

</div>

> unction buttonPressed(n) {  
> if (firstButtonPress == true) {  
> mainClip.gotoAndPlay(“pageIn”+n);  
> firstButtonPress = false;  
> } else {  
> buttonCollection[‘b’+currentButton].gotoAndPlay(‘out’);  
> buttonCollection[‘b’+currentButton].enabled = true;  
> mainClip.gotoAndPlay(“pageOut”+currentButton);  
> }  
> this look wrong

i think I need to see the fla to make sense, sounds like you code is all over the place
