# Controle multiple movies with a for loop: need help!

**URL:** https://forum.kirupa.com/t/controle-multiple-movies-with-a-for-loop-need-help/129483
**Category:** Uncategorized
**Created:** [November 24, 2004, 6:46am UTC](https://forum.kirupa.com/t/controle-multiple-movies-with-a-for-loop-need-help/129483 "2004-11-24T06:46:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![humbleches](https://avatars.discourse-cdn.com/v4/letter/h/6de8d8/32.png) [@humbleches](https://forum.kirupa.com/u/humbleches)
#### Post date: [November 24, 2004, 6:46am UTC](https://forum.kirupa.com/t/controle-multiple-movies-with-a-for-loop-need-help/129483/1 "2004-11-24T06:46:47Z")

</div>

Hi, I have 18 movie clips on the \_root timeline called (1,2,3…18) that I want to control at the same time and with the same instructions. I want them all to have the same behaviour. I’m trying to avoid typing out the same thing for 18 clips if at all possible!

This is what I’ve got but it isn’t working. The srcipt works okay if it’s not in the for loop.

```php
stop();
  xspeed = 1;
  yspeed = 2;
  for(movie = 0,movie<19,movie++){
  	[movie].onEnterFrame = function(){
  		[movie].onRollOver = function() {
  			this.play();
  		}
  		[movie].onRollOut = function(){
  			this.gotoAndPlay(11);
  		}
  		[movie]._x += [movie].xspeed;
  		if ([movie]._x < 140 || [movie]._x > 610){
  			[movie].xspeed *= -1;
  		}
  		[movie]._y += [movie].yspeed;
  		if([movie]._y<140 || [movie]._y>391){
  			[movie].yspeed *= -1;
  		}
  	}
  }

```

I’m trying to move them and use them as buttons at the same time. Is that possible or have I made some probably simple muck up??

Any advice/help very much appreciated! Cheers,

Tim
