Jump to content
Search Community

ash allen

Members
  • Posts

    12
  • Joined

  • Last visited

ash allen's Achievements

0

Reputation

  1. Hi - thanks for the suggestion, I will give that a go.
  2. 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; } } }
  3. Hi Carl, thanks for the suggestions, I haven't had time to check out the sound control as I am having trouble loading onto the device. I'm using an Asus Nexus - everything is working in Flash but when I deploy to the device only the first swf file is playing and then everything stops. Do you have any suggestions on how to debug this? Thanks!
  4. Hi, I'm having trouble with the initial loading of my swf file. - it is visible and audible before it's fully loaded so it shows on stage as though it's paused but the sound is playing. The progress bar is visible on top of the loading swf. How do I make it visible and audible only once it's fully loaded? If I put the following code: event.target.content.visible = false; SoundMixer.soundTransform = new SoundTransform(0); in the progressHandler event the sound and image is hidden but I'm not sure where to restart it once progress equals 1. If I restart it in completeHandler it does exactly what I've mentioned above. Here is my code: Thanks. public class main extends MovieClip { private var currentSWFLoader:SWFLoader; private var swf1:SWFLoader = new SWFLoader("movie1.swf",{container:this,autoPlay:false, width:480,height:480,x:300,scaleMode:"proportionalInside", onComplete:completeHandler,onProgress:progressHandler, onChildComplete:childCompleteHandler}); public function CyberWalkColourSound() { progress_mc.scaleX = 0; } //LOAD MOVIE ONE; private function loadmovie1(event:MouseEvent):void { currentSWFLoader = swf1; currentSWFLoader.load(true); } function progressHandler(event:LoaderEvent):void { progress_mc.scaleX = event.target.progress; trace("progress: " + event.target.progress); progress_mc.visible = true; setChildIndex(progress_mc, numChildren - 1); } function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); } function completeHandler(e:LoaderEvent):void { progress_mc.visible = false; currentSWFLoader.rawContent.play(); trace(currentSWFLoader.rawContent + "playing"); }
  5. I got i working by changing container:movieTwo_mc to container:this
  6. Hi, Any chance someone might know why I can't see my loaded swf files. I can hear the audio and the trace statements says they are loaded, but they are not visible. I'm guessing it has something to do with the container. I'm hoping you can see something obvious in my code. Thanks. public class Main extends MovieClip { private var currentSWFLoader:SWFLoader; private var swf1:SWFLoader = new SWFLoader("movie1.swf", {container:movieTwo_mc, autoPlay:false, width:480, height:480, x:300,scaleMode:"proportionalInside",onComplete:completeHandler}); private var swf2:SWFLoader = new SWFLoader("movie2", {container:movieTwo_mc, autoPlay:false, width:480, height:480, x:300, scaleMode:"proportionalInside",onComplete:completeHandler}); public function Main() { homePage_mc.movieOne_btn.addEventListener(MouseEvent.CLICK, loadOne); homePage_mc.movieTwo.addEventListener(MouseEvent.CLICK, loadTwo); } //LOAD MOVIE ONE; private function loadOne(event:MouseEvent):void { trace("one"); currentSWFLoader = swf1; currentSWFLoader.load(true); homePage_mc.movieOne_btn.removeEventListener(MouseEvent.CLICK, loadOne); } private function loadRed(event:MouseEvent):void { trace("two"); currentSWFLoader = swf2; currentSWFLoader.load(true); homePage_mc.movieTwo_btn.removeEventListener(MouseEvent.CLICK, loadTwo); } function completeHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.rawContent.play(); homePage_mc.visible = false; btnListener(); } private function btnListener():void { home_btn.addEventListener(MouseEvent.CLICK,resetScreens); } //RESET SCREENS; public function resetScreens(event:MouseEvent):void { currentSWFLoader.unload(); home_btn.removeEventListener(MouseEvent.CLICK,resetScreens); homePage_mc.visible = true; trace("reset screens"); } } }
  7. Ah - thanks for pointing that out. Also I found where I went wrong in my code and have managed to re-use the loader code correctly - yay! Actually I'm still having problems. I can get a second array of swfs to play by replicating all the code, but then I get this message: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mainGSsound/trackSWFPlayback() and it breaks. I'm not sure how to fix this? Here is how I have replicated the code (using code listed above). I have been going through other forum posts to see if I can re-use the loaders but this is the only way I have made it work. private var currentLoader:SWFLoader; private var currentLoader2:SWFLoader; private var swfs1:LoaderMax = new LoaderMax({onComplete:completeHandler,onChildComplete:childCompleteHandler}); private var swfs2:LoaderMax = new LoaderMax({onComplete:completeHandler2,onChildComplete:childCompleteHandler2}); private var urls:Array = ["movie0.swf","movie1.swf","movie2.swf"]; private var urls2:Array = ["swf0.swf", "swf1.swf", "swf.swf"]; //I use this code to switch between screens/movies public function resetScreens(event:MouseEvent):void { if (level == "ONE") { swfs1.unload(); } if (level == "TWO") { swfs2.unload(); } homePage_mc.visible = true; } Thanks.
  8. Hi again - I tried replacing the code, but have come up with this error: 1119: Access of possibly undefined property width through a reference with static type com.greensock.loading:SWFLoader. Is there a shorthand way to add it in here with x: , y: ?: swfs.append( new SWFLoader(urls, {container:movieTwo_mc, autoPlay:false, width:480, height:480, scaleMode:"proportionalInside"}) ); I've also been trying all day to get a second array of swfs to load. I have tried various things including splicing the array and creating a second swfLoader - but the original array is always there. It stops playing when I go back to the homepage but when I press the second button I get the original array plus the new swfs. Any advice on how to get a second array to play would be greatly appreciated. Thanks.
  9. Hi Carl - thanks for your suggestions. I want to center the ImageLoaders content on the stage. Previously I was using the below code but I'm not sure how to write that for loadermax. loader.x = (stage.stageWidth/2 - loader.width/2); loader.y = (stage.stageHeight/2 - loader.height/2); I'm new to coding and using classes, I've been playing around with them today but can't seem to get a second array to load. I'll keep hunting for more tutorials! cheers, Ashleigh
  10. Hi, I have found the following code to loop through an array of swf's - which works really smoothly (thanks). I would like to re-use this code to load other arrays of swf's. Could I make a separate class so I could re-use the code in a more streamlined way rather than pasting it over and over (any advice how to do this would be great)? Also how can I center the x and y co-ordinates of the loader? Thanks! import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; private var loaderIndex:Number = -1; private var currentLoader:SWFLoader; private var urls:Array = ["movie0.swf","movie1.swf","movie2.swf",]; private var swfs:LoaderMax = new LoaderMax({onComplete:completeHandler,onChildComplete:childCompleteHandler}); private function startMovieOne(event:MouseEvent):void { homePage_mc.visible = false; // 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:movieTwo_mc, autoPlay:false, width:480, height:480, scaleMode:"proportionalInside"}) ); } swfs.load(); btnListener(); } function childCompleteHandler(e:LoaderEvent):void { trace(e.target + " loaded"); e.target.content.visible = false; } function completeHandler(e:LoaderEvent):void { trace("all swfs loaded"); 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(); } } private function btnListener():void { home_btn.addEventListener(MouseEvent.CLICK,resetScreens); } public function resetScreens(event:MouseEvent):void { //unload content currentLoader.content.visible = false; currentLoader.rawContent.stop(); trace("unloaded"); homePage_mc.visible = true; }
  11. Hi - thanks, yes that did help loop the files, but didn't quite achieve what I wanted, and now I look at the code I realise I'm tackling what I want to do the wrong way, so I'm going back to the drawing board!
  12. 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(); }
×
×
  • Create New...