AS3:等多个装载机完成 [英] AS3: waiting for multiple loaders to complete

查看:179
本文介绍了AS3:等多个装载机完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的图像要加载任意数量。我想加载它们,等到我得到一个Event.INIT每个,然后才继续进行程序的其余部分。

I have an arbitrary number of images I want to load. I want to load them, wait until I get an Event.INIT for each, and only then proceed with the rest of the program.

我知道我可以通过具有Event.INIT监听器更新和检查一些计数变量做的,但是是标准的做法?是否有一个更优雅或AS-特定的方式?

I know I can do that by having an Event.INIT listener update and check some count variable, but is that the standard approach? Is there a more elegant or AS-specific way?

推荐答案

最好的办法是使用LoaderMax,由greensock(TweenMax的开发商)开发的。

The best way is to use LoaderMax, developed by greensock (the developer of TweenMax).

http://www.greensock.com/loadermax/

您可以创建一个装载组,等待complete事件该组。在code被记录得非常好。

You can create a loading group and wait for the complete event for that group. The code is documented very well.

下面是code快速样机来给你,你可以期待一个想法:

Here is a quick mockup of code to give you an idea about what you can expect:

mediaLoader = new LoaderMax( { name:"mediaLoader" } );
mediaLoader.addEventListener(LoaderEvent.PROGRESS, onMediaLoadProgress);
mediaLoader.addEventListener(LoaderEvent.COMPLETE, onMediaLoadComplete);
mediaLoader.addEventListener(LoaderEvent.ERROR, onMediaLoadError);

for (var i:int = 0; i < 10; i++)
{
    mediaLoader.append(LoaderMax.parse("image_" + i + ".jpg", { estimatedBytes: 100000 }));
}

这也为您提供了专门的装载机的图片,视频,声音等,您可以使用它们来你的优势,或者只是透明地对待他们。

It also gives you specialized loaders for images, video, sound, etc. You can use them to your advantage, or just treat them transparently.

这篇关于AS3:等多个装载机完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆