# as3 - external swf array - next & prev button

**URL:** <https://forum.kirupa.com/t/as3-external-swf-array-next-prev-button/313960>\
**Category:** flash\
**Created:** [September 14, 2010, 8:15pm UTC](https://forum.kirupa.com/t/as3-external-swf-array-next-prev-button/313960 "2010-09-14T20:15:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![noonoo11](https://avatars.discourse-cdn.com/v4/letter/n/a8b319/32.png) [@noonoo11](https://forum.kirupa.com/u/noonoo11)\
**Post date:** [September 14, 2010, 8:15pm UTC](https://forum.kirupa.com/t/as3-external-swf-array-next-prev-button/313960/1 "2010-09-14T20:15:06Z")

</div>

Hey guys,

I hope someone could help a newbie out or point me in the right direction.

I got a pretty simple setup with a main swf that loads in external swf trough an array… I created a “next” and “prev” button - attempting to load the next or previous external swf from that array…

Next function is working but previous function is not really.  
(on first click it doesn’t do anything - and then error messages)  
I have no idea why… been trying every modification i can think of to the code but no luck…

Here my code:

```php
var clips:Array = ["a.swf", "b.swf", "c.swf"];
var index:int = 0;

var thisLoader:Loader = new Loader(); 
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);

var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC);			

function nextClip():void {
	thisLoader.load(new URLRequest(clips[index]));
}

function prevClip():void {
	thisLoader.load(new URLRequest(clips[index]));
}

function doneLoading(e:Event):void {
	stage.removeChild(thisMC);
	thisMC = MovieClip(thisLoader.content);
	thisLoader.unload();
	stage.addChild(thisMC);
	thisMC.play();
}

btnNext.addEventListener(MouseEvent.CLICK, playNext);

function playNext(e:MouseEvent):void {
	nextClip();
	index = (index + 1)%(clips.length);
}

btnPrev.addEventListener(MouseEvent.CLICK, playPrev);

function playPrev(e:MouseEvent):void {
	prevClip();
	index = (index - 1)%(clips.length);
}

```

Please Help…  
Thank you so much in advance guys.  
:hr:
