基于 AS3 预加载器进度百分比的 gotoAndPlay 帧
我遵循了这个优秀的as3预加载器教程,下面是我到目前为止的代码。
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
trace("loading...");
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
trace("done!");
}
这完美地加载了主要内容。显示加载进度的百分比。
现在我想更进一步。我的目标是在时间轴上的 3 个不同帧中显示 3 张图像,其中一张在完成 25% 时可见,第二张在完成 50% 时可见,最后一张图像在完成 75% 时可见。
我假设我需要添加一些 if 语句,但我无法弄清楚监听 flash 百分比以了解要移动到哪个帧的语法是什么。
感谢您的阅读,非常感谢任何帮助。
i followed this excellent as3 preloader tutorial, and below is the code i have so far.
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("content.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
trace("loading...");
}
function done(e:Event):void
{
removeChildAt(0);
percent = null;
addChild(l);
trace("done!");
}
this loads the main content perfectly. displaying the percent of the loading progress.
now i'd like to take it a step farther. my goal is to have 3 images in 3 different frames on a timeline and have one become visible on 25% done, the second on 50% done, and the final image on 75% done.
i'm assuming i need to add some if statements but i'm having trouble figuring out what the syntax would be to listen for the percentage for flash to know what frame to move to.
thanks for reading and any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将一个名为
movieClipWithImages
的影片剪辑添加到舞台上,其中包含 3 个图像(每帧一个),然后使用以下代码。Add a movie clip called
movieClipWithImages
with the 3 images, one on each frame, to the stage, and then use the following code.