开发者

Flash AS3: Loading bar not finished when movie starts playing

开发者 https://www.devze.com 2022-12-24 22:50 出处:网络
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

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开发者_StackOverflow社区 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);
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号