Hello guys,
I hope that you can help me with some functionality problems. I want to load external swfs into the main movie and then control them (previous | stop | next). I already had put together some code but I’m missing a way on how to know exactly which is the current movie clip loaded (index variable) in order to use it for next / previous buttons. I know it must be fairly simple but I think I lack the knowledge. :ninja:
So for now I have two SWFs for test (screen1 & screen2) and the scene is loading movie clip after movie clip non-stop. I already have the stop button but I need functionality correctly integrated for previous / next buttons. Anyone that might have a big heart and want to help me? :bu:
Cheers!!!
var clips:Array = ["screen1.swf", "screen2.swf"];
var index:int = 0;
var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);
var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC);
stage.setChildIndex(thisMC,0);
function nextClip():void {
thisLoader.load( new URLRequest(clips[index]) );
}
function previousClip():void {
thisLoader.load( new URLRequest(clips[index]) );
}
function doneLoading(e:Event):void {
stage.removeChild(thisMC);
thisMC = MovieClip(thisLoader.content);
thisLoader.unload();
thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
stage.addChild(thisMC);
stage.setChildIndex(thisMC,0);
thisMC.gotoAndPlay(1);
}
function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
index = (index + 1)%(clips.length);
nextClip();
}
}
stopB.addEventListener(MouseEvent.CLICK, stopMotion);
function stopMotion(evt:MouseEvent):void {
thisMC.stop();
}
nextB.addEventListener(MouseEvent.CLICK, playNext);
function playNext(e:MouseEvent):void {
nextClip();
}
previousB.addEventListener(MouseEvent.CLICK, playPrevious);
function playPrevious(e:MouseEvent):void {
nextClip();
}
nextClip();