Flash AS3:电影开始播放时加载栏未完成

发布于 2024-08-26 07:07:31 字数 912 浏览 6 评论 0原文

我使用的代码与我总是用于预加载另一个 swf 的代码相同,但这次不起作用。这次的问题是,当加载条达到 16% 时,每次您都可以听到我正在加载的电影在后台播放。我可以在正在加载的电影的第一帧(“Trial_1.swf”)中添加一个停止点,但是如何告诉它在加载后转到第二帧?

非常感谢任何帮助!

这是我的代码:

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);
}

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);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一直在等你来 2024-09-02 07:07:31

为什么不在 Trial_1.swf 的开头放置一个特殊的起始帧(以及第一帧上的 stop();),其中按钮保持“开始电影”。单击该按钮时,它会使用 gotoAndPlay(2); 将时间线移动到第 2 帧。

如果您这样做,则由用户决定何时开始播放动画,并且只有在完全加载且 swf 位于舞台上后才能完成。那应该可以解决你的问题。

但说实话,我不确定为什么你的动画在完全加载之前就开始播放。这确实很奇怪。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文