# \[FMX2004\]\[AS1\] Function/Looping

**URL:** <https://forum.kirupa.com/t/fmx2004-as1-function-looping/148941>\
**Category:** flash\
**Created:** [May 24, 2005, 8:24pm UTC](https://forum.kirupa.com/t/fmx2004-as1-function-looping/148941 "2005-05-24T20:24:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tico](https://avatars.discourse-cdn.com/v4/letter/t/a88e57/32.png) [@tico](https://forum.kirupa.com/u/tico)\
**Post date:** [May 24, 2005, 8:24pm UTC](https://forum.kirupa.com/t/fmx2004-as1-function-looping/148941/1 "2005-05-24T20:24:03Z")

</div>

Hi,

i’m making a menu (some kind of slideshow) that plays diferents movieclips.  
the switch between movieclips is made through buttons and the Left/Right Key.  
Because of the transition between the current displayed movieClip and the next movieClip, i need to play both movieclips at the same time.

So far, i’ve made the menu this way:

Forward

_myButton1.onPress = function() {  
if (\_root.MovieClip1.\_currentframe == 10) {  
\_root.MovieClip1.play();  
\_root.MovieClip2.play();  
} else if (\_root.MovieClip2.\_currentframe == 10) {  
\_root.MovieClip2.play();  
\_root.MovieClip3.play();  
 [size=1] ////(and so on…)[/size]  
}  
};_

Backward

_myButton2.onPress = function() {  
if (\_root.MovieClip2.\_currentframe == 10) {  
\_root.MovieClip2.play();  
\_root.MovieClip1.play();  
} else if (\_root.MovieClip3.\_currentframe == 10) {  
\_root.MovieClip3.play();  
\_root.MovieClip2.play();  
 [size=1] ////(and so on…)[/size]  
}  
};_

…well, i need to make that for 20 movieclips… or maybe more, or maybe less… :bored:  
and then, i’ve to repeat that for each button, and for each key… and the thing gets a kind of messy… 😏

So, what do i need is a global function, simpler, without have to make all the conditions for each movieclip.  
I know that it’s possible to make it with looping, but can figure out how. :puzzled:

I would apreciate some help with the function… :}
