views:

283

answers:

1

Hi, I'm using the same code I always use for preloading another swf but it's not working this time. The problem this time is that when the loading bar gets to 16% every time you can hear the movie I'm loading playing in the background. I can just add a stop to the first frame of the movie I'm loading ("trial_1.swf") but how do I tell it to go to the second frame once it has loaded?

Any help is much appreciated!

Here's my code:

var myrequest:URLRequest=new URLRequest ("trial_1.swf");

var myloader:Loader = new Loader();
myloader.load(myrequest);

myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progresshandler);
function progresshandler(myevent:ProgressEvent):void {

var myprogress:Number=myevent.target.bytesLoaded/myevent.target.bytesTotal; bar_mc.scaleX=myprogress*1.5; myTextField_txt.text = Math.round(myprogress*100)+"%"

}

myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, finished);
function finished(myevent:Event):void {

addChild(myloader); removeChild(myTextField_txt) removeChild(bar_mc);

removeChild(logo_mc);

}
A: 

Why not put a special starting frame at the beginning of your trial_1.swf (along with the stop(); you've got on that first frame) which has as button staying 'Start Movie'. When the button is clicked, it moves the timeline to frame 2 with gotoAndPlay(2);.

If you do it like that it's up to the user when to start playing the animation, and it can only be done once it's loaded fully, and the swf is on the stage. That should solve your problem.

To be honest though, I'm not sure why your animation is beginning to play before it's fully loaded. That's certainly odd.

debu
Thanks, that's just what I've done to get around it! I know it's weird though!! Thanks again for your help.
flashey
No problem, glad it's solved :)
debu