# Play random movie clip

**URL:** <https://forum.kirupa.com/t/play-random-movie-clip/5741>\
**Category:** Uncategorized\
**Created:** [September 20, 2002, 6:54pm UTC](https://forum.kirupa.com/t/play-random-movie-clip/5741 "2002-09-20T18:54:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuga](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shuga](https://forum.kirupa.com/u/shuga)\
**Post date:** [September 20, 2002, 6:54pm UTC](https://forum.kirupa.com/t/play-random-movie-clip/5741/1 "2002-09-20T18:54:11Z")

</div>

i have a series of movie clip instances (of the same movie) on the stage all numbered 0 through 15

its a simple experiment but i can’t get it to work

heres what i want to do

i want

```auto

onClipEvent(enterFrame){
	i=random(15);
	"i".gotoAndPlay(2);
}

```

to work

i have the actionscript on a clip called controller that is on the main stage.

i want it to choose a random number between 0 and 15 and then play that number’s corresponding instance of the movieclip

this is possible i think … i’m sure i’m just missing something simple

thanks in advance for the help.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2002, 7:06pm UTC](https://forum.kirupa.com/t/play-random-movie-clip/5741/2 "2002-09-20T19:06:27Z")

</div>

[COLOR=blue]onClipEvent (enterFrame) {  
i = random(15);  
\_root\*.gotoAndPlay(2);  
}[/COLOR]

When referring to variables that are integers (numbers) lose the quotes.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2002, 7:07pm UTC](https://forum.kirupa.com/t/play-random-movie-clip/5741/3 "2002-09-20T19:07:46Z")

</div>

and use \_root because the movie clips are not sub clips of your controller clip.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 20, 2002, 7:47pm UTC](https://forum.kirupa.com/t/play-random-movie-clip/5741/4 "2002-09-20T19:47:28Z")

</div>

it works … thank you
