# Loading external .swf from an array in array order

**URL:** <https://forum.kirupa.com/t/loading-external-swf-from-an-array-in-array-order/329714>\
**Category:** Uncategorized\
**Created:** [October 5, 2012, 4:51pm UTC](https://forum.kirupa.com/t/loading-external-swf-from-an-array-in-array-order/329714 "2012-10-05T16:51:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sgershen](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sgershen](https://forum.kirupa.com/u/sgershen)\
**Post date:** [October 5, 2012, 4:51pm UTC](https://forum.kirupa.com/t/loading-external-swf-from-an-array-in-array-order/329714/1 "2012-10-05T16:51:48Z")

</div>

[COLOR=#333333][FONT=adobe-clean]I was wondering if someone can help me out. The code below demonstrates pulling in multiple .swf from an array and plays each one randomally when the "main .swf re-publishes each time. I cant figure out how to play each .swf in the order that specifies in the array.

example: \*\*I want the main .swf to play ‘clip0’,‘clip1’,‘clip2’ in that specific order not random.

"when I publish out the .swf i want it to play clip0, then if I publish it out again I want it to publish out clip1, etc… in that specific order each time I re publish.\*\*

Can someone assist me.

------code-------------

stop();[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]var movieArray:Array = [‘clip0’,‘clip1’,‘clip2’];[/FONT][/COLOR]

[COLOR=#333333][FONT=adobe-clean]var loader:Loader = new Loader();[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]var index:int = movieArray.length \* Math.random();[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]var url:String = movieArray[index] + ‘.swf’;[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]trace(“Attempting to load”, url);[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]loader.load(new URLRequest(url));[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO\_ERROR, loaderIOError);[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]addChild(loader);[/FONT][/COLOR]

[COLOR=#333333][FONT=adobe-clean]function loaderComplete(e:Event):void {[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean] trace(“Successfully loaded”, url);[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]}[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]function loaderIOError(e:IOErrorEvent):void {[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean] trace(“Failed to load”, url);[/FONT][/COLOR]  
[COLOR=#333333][FONT=adobe-clean]}[/FONT][/COLOR]
