Jump to content
Search Community

dragon

Members
  • Posts

    3
  • Joined

  • Last visited

dragon's Achievements

0

Reputation

  1. Hi all... Is there anyone here??? I've found a simple but useful code developed a few years ago... it loads 2 swf files in sequence ... But I have just one question... How can I Loop them? How can you change the code to load swf1 after swf2 is finished? I've tried almost the whole day but no result yet... Please help... thank you a lot... import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.events.Event; //create SWFLoaders var swf1:SWFLoader = new SWFLoader("child1.swf",{container:this,y:100,onProgress:progressHandler,onComplete:completeHandler,autoPlay:false}); var swf2:SWFLoader = new SWFLoader("child2.swf",{container:this,y:100,onProgress:progressHandler,onComplete:completeHandler,autoPlay:false}); var currentSWFLoader:SWFLoader = swf1; //adjust the progress bar; function progressHandler(e:LoaderEvent):void { bar.scaleX = e.target.progress; trace(e.target.progress); } //tell the loaded swf to play and start tracking frames function completeHandler(e:LoaderEvent):void { //the target of the LoaderEvent is the SWFLoader that fired the event //the rawContent is the loaded swf e.target.rawContent.play(); addEventListener(Event.ENTER_FRAME, checkFrame); } function checkFrame(e:Event):void { //check to see if loaded swf is done playing if (currentSWFLoader.rawContent.currentFrame == currentSWFLoader.rawContent.totalFrames) { trace("swf done playing"); removeEventListener(Event.ENTER_FRAME, checkFrame); //if the first swf is done playing load the second swf if (currentSWFLoader == swf1) { currentSWFLoader.dispose(true) // dispose and unload content currentSWFLoader = swf2; currentSWFLoader.load(); } } } bar.scaleX = 0; currentSWFLoader.load();
  2. Hi all... Based on one of your Great Codes I developed this one : It is all about 4 SWF files that will be load one after another then it stores last swf you ran when you close it ( when you exit each one it will be load next time exactly the same SWF you've exited). for example if you close swf number 3 , next time you start the main swf you will start from SWF number 3... But there is a big problem here ... Each of my SFWs are about 10 to 16 Mb (I didn't create them with flash) and unfortunately your code seem to load all of them at once ... then play them in sequence ... I have to load more than 100 SWF files and it will definitely cause RAM issue ... Each one cost me 10-16MB... I'm not a programmer but I'm thinking why showing multiple SWF files and remembering where you left is that hard in 2018 ??? ... Please Help me find a way to load swfs one after another and save last status of it ... You're My Last Hope Carl ... Thanks import flash.events.FullScreenEvent; import flash.display.StageScaleMode; stage.scaleMode = StageScaleMode.SHOW_ALL; 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("edfiujy6grwfh"); var reza:Number = -1; 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); reza = loaderIndex trace(reza); 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); //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. */
  3. 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. */
×
×
  • Create New...