dragon Posted October 12, 2017 Posted October 12, 2017 hey , Hi Hello ... I have read your answer to this topic : that's awesome and a smart guy developed it a little bit (tnx to a user asked about the same problem) ... add saving what swf lastly loaded (using shared object) and fade in loading swf etc ... Now it's all great but I faced a big problem in my output : Error 2006 The Supplied Index is Out of Bounds How can I get ride of this ... any help is appreciated... stackoverflow is a mess to solve this ... tnx for your help carl the code : import flash.events.FullScreenEvent; import flash.display.StageScaleMode; stage.scaleMode = StageScaleMode.EXACT_FIT; stage.displayState = StageDisplayState.FULL_SCREEN; import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; import flash.net.SharedObject; import flash.events.MouseEvent; var mySO:SharedObject = SharedObject.getLocal("saver"); var loaderIndex:Number = -1; loaderIndex = mySO.data.my_vis; if (!mySO.data.my_vis) { loaderIndex = -1; } if (mySO.data.my_vis == 1) { loaderIndex = 0; } if (mySO.data.my_vis == 2) { loaderIndex = 1; } if (mySO.data.my_vis == 3) { loaderIndex = 2; } if (mySO.data.my_vis == 4) { loaderIndex = 3; } progress_mc.scaleX = 0; var currentLoader:SWFLoader; var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler}); swfs.append(new SWFLoader("part1.swf", {container:this.stage, autoPlay:false})); swfs.append(new SWFLoader("part2.swf", {container:this.stage, autoPlay:false})); swfs.append(new SWFLoader("part3.swf", {container:this.stage, autoPlay:false})); swfs.append(new SWFLoader("part4.swf", {container:this.stage, autoPlay:false})); function progressHandler(e:LoaderEvent):void { progress_mc.scaleX = e.target.progress; } function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.content.visible = false; } function completeHandler(e:LoaderEvent):void { trace("all swfs loaded"); progress_mc.visible = false; initCurrentLoader(); addEventListener(Event.ENTER_FRAME, trackSWFPlayback); } function initCurrentLoader() { loaderIndex++; trace(loaderIndex); mySO.data.my_vis = loaderIndex; mySO.flush (); if (loaderIndex == swfs.numChildren) { //reset back to 0 if the last swf has already played //loaderIndex = 0; //can't show stuff that was unloaded so lets stop mySO.clear(); loaderIndex = -1 swfs.load(); trace("all done everyone gone"); removeEventListener(Event.ENTER_FRAME, trackSWFPlayback); } else { //dynamically reference current loader based on value of loaderIndex currentLoader = swfs.getChildAt(loaderIndex); trace(currentLoader); trace(loaderIndex); //make the content of the current loader visible currentLoader.content.visible = true; //fade it in TweenLite.from(currentLoader.content, 0.1, {alpha:1}); //tell the current loader's swf to to play currentLoader.rawContent.gotoAndPlay(1); } } function trackSWFPlayback(e:Event):void { //trace(currentLoader.rawContent.currentFrame); //detect if the loaded swf is on the last frame if (currentLoader.rawContent.currentFrame == currentLoader.rawContent.totalFrames) { trace("swf done"); //hide and stop current swf currentLoader.content.visible = false; currentLoader.rawContent.stop(); //unload the swf that just played currentLoader.unload(); //set up and play the next swf initCurrentLoader(); } } this.addEventListener(Event.ENTER_FRAME, loadSWFs) function loadSWFs(e:Event):void{ load_btn.visible = false; swfs.load(); this.removeEventListener(Event.ENTER_FRAME, loadSWFs) } /* Click to Hide an Object Clicking on the specified symbol instance hides it. Instructions: 1. Use this code for objects that are currently visible. */
Carl Posted October 12, 2017 Posted October 12, 2017 I'm guessing the error is happening around here: currentLoader = swfs.getChildAt(loaderIndex); As the stack overflow post states you are probably trying to access an index beyond what it is in the array returned by getChildAt(). It looks like you commented out important code that prevents the loaderIndex from getting too high if (loaderIndex == swfs.numChildren) { //reset back to 0 if the last swf has already played //loaderIndex = 0; //can't show stuff that was unloaded so lets stop mySO.clear(); loaderIndex = -1 swfs.load(); trace("all done everyone gone"); removeEventListener(Event.ENTER_FRAME, trackSWFPlayback); } since you are only incrementing loaderIndex using loaderIndex++ and never reseting it, my only assumption is that it gets too high. Hopefully this helps. Unfortunately we just don't have the resources to be digging into custom code in AS3 projects. We stopped supporting the AS3 stuff awhile ago. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now