Share Posted June 12, 2013 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"); } Link to comment Share on other sites More sharing options...
Share Posted June 12, 2013 For the visibility of the swf, you should set its alpha to 0 in the SWFLoader constructor: new SWFLoader("movie1.swf",{container:this,autoPlay:false, width:480,height:480,x:300,scaleMode:"proportionalInside", onComplete:completeHandler,onProgress:progressHandler, onChildComplete:childCompleteHandler, alpha:0}); use the onComplete handler to show it function completeHandler(e:LoaderEvent):void { progress_mc.visible = false; currentSWFLoader.rawContent.play(); trace(currentSWFLoader.rawContent + "playing"); e.target.content.alpha = 1 //or use a tween } As for the sound, I don't know how that is controlled in your loaded swf. autoPlay:false only prevents the playhead in the loaded swf from advancing. It doesn't abort any function calls inside your swf. I would suggest you have a method in your loaded swf called something like playSound() initialise your Sound Object and start the playing of its sound, and then call that method from the onComplete handler function completeHandler(e:LoaderEvent):void { progress_mc.visible = false; currentSWFLoader.rawContent.play(); trace(currentSWFLoader.rawContent + "playing"); e.target.content.alpha = 1 //or use a tween e.target.rawContent.playSound(); } See if that works. Link to comment Share on other sites More sharing options...
Author Share Posted June 15, 2013 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! Link to comment Share on other sites More sharing options...
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