Search the Community
Showing results for tags 'swfs'.
-
Hi - I have an app working in flash but when I deploy to a device only the first swf loads then unloads and nothing else happens. I'm not sure how to debug what is happening on the device. I am loading several swfs using loadermax - some of the code is below and I will note where it stops working: Grateful for any advice, am currently thinking of starting again without using GS code to see if I'm doing something wrong in there. Thanks. private var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler}); private function buttonListeners():void { homePage_mc.start_btn.addEventListener(MouseEvent.CLICK, loadswfs); } //LOAD MOVIES; private function loadswfs(event:MouseEvent):void { swfs.append(new SWFLoader("Movie1.swf",{container:this,autoPlay:false,width:480,height:480,x:300,scaleMode:"proportionalInside"})); swfs.append(new SWFLoader("Movie2.swf",{container:this,autoPlay:false,width:480,height:480,x:300,scaleMode:"proportionalInside"})); // there are 8 more swfs loaded this way swfs.load(true); loadMovie1(); homePage_mc.start_btn.removeEventListener(MouseEvent.CLICK, loadswfs); } private function loadMovie1():void { swfName = "1"; trace("Movie1"); currentSWFLoader = LoaderMax.getLoader("Movie1.swf"); } private function loadMovie2():void { swfName = "2"; currentSWFLoader = LoaderMax.getLoader("Movie2.swf"); trace(currentSWFLoader.content); initCurrentSWFLoader(); // this swf doesn't start playing on device - it does in Flash } //SWF LOADER EVENTS; function progressHandler(event:LoaderEvent):void { progress_mc.scaleX = event.target.progress; trace("progress: " + event.target.progress); } function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.content.visible = false } function completeHandler(e:LoaderEvent):void { trace("all loaded"); progress_mc.visible = false; initCurrentSWFLoader(); } function initCurrentSWFLoader() { currentSWFLoader.content.visible = true; currentSWFLoader.rawContent.gotoAndPlay(1); trace(currentSWFLoader.rawContent.name + "playing"); addEventListener(Event.ENTER_FRAME, trackSWFPlayback); } function trackSWFPlayback(e:Event):void { if (currentSWFLoader.rawContent.currentFrame == currentSWFLoader.rawContent.totalFrames) { removeEventListener(Event.ENTER_FRAME, trackSWFPlayback); switch (swfName) { case "1" : currentSWFLoader.content.visible = false; currentSWFLoader.rawContent.stop(); loadMovie2(); break; case "2" : currentSWFLoader.content.visible = false; currentSWFLoader.rawContent.stop(); loadMovie3(); break; } } }
- 2 replies
-
- debugging devices
- loading
-
(and 2 more)
Tagged with:
-
Hi - I'm new to using greensock (and actionscript) and am trying to play around with some code I found. It originally loaded several swf files and looped through them continuously - I'm trying to randomize it. I have created an array and added code to shuffle through the array, but I'm stuck trying to integrate it into the looping files. I'm pretty sure I have to do something with the loaderIndex, but I'm not sure what. Any help would be great - thanks. Code: progress_mc.scaleX = 0; var loaderIndex:Number = -1; var currentLoader:SWFLoader; var urls:Array = ["SWF0.swf","SWF1.swf","SWF2.swf"]; var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onProgress:progressHandler,onChildComplete:childCompleteHandler}); // Loop through urls and create a queue of swf loaders for (var i:Number = 0; i < urls.length; i++) { swfs.append( new SWFLoader(urls, {container:container_mc, autoPlay:false}) ); } urls.sort(randomSort); function randomSort(a:*, b:*):Number { if (Math.random() < 0.5) { return -1; } else { return 1; } } 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++; if (loaderIndex == swfs.numChildren) { //reset back to 0 if the last swf has already played loaderIndex = 0; } //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; //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(); //set up and play the next swf; initCurrentLoader(); } } load_btn.addEventListener(MouseEvent.CLICK, loadSWFs); function loadSWFs(e:MouseEvent):void { load_btn.visible = false; swfs.load(); }