flash as3 movieClip 加载器未按数字顺序加载
我正在加载一个影片剪辑数组并使用 flash as3 将它们添加到舞台上,但问题是影片剪辑在完成加载后立即添加到舞台上,而不是按照数组中位置的顺序,所以屏幕上的顺序显得混乱。如何确保它们按照其引用在 URL 中存在的顺序添加到舞台中?这是我的代码:
var currentLoaded:int = 0;
function loadThumbs(){
for (var i in project_array){
var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(project_array[i].project_thumb));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
}
}
function thumbLoaded(e:Event):void {
project_array[currentLoaded].projectThumb.thumbHolder.addChild(e.target.content);
admin.slideHolder.addChild(project_array[currentLoaded].projectThumb);
currentLoaded++;
}
I am loading an array of movie clips and adding them to the stage with flash as3, but the problem is that the movie clips are added to the stage as soon as they finish loading, and not in order of there position in the array, so the order on screen appears messed up. How do I ensure that they are added to the stage in the same order that their references exist in the URL? Here is my code:
var currentLoaded:int = 0;
function loadThumbs(){
for (var i in project_array){
var thumbLoader:Loader = new Loader();
thumbLoader.load(new URLRequest(project_array[i].project_thumb));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
}
}
function thumbLoaded(e:Event):void {
project_array[currentLoaded].projectThumb.thumbHolder.addChild(e.target.content);
admin.slideHolder.addChild(project_array[currentLoaded].projectThumb);
currentLoaded++;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,我只是输入相同的解决方案......
要以某种特定顺序加载,您必须使其递归。
您可以尝试 greensock 的 loadermax 库。坚如磐石、快速且轻量。
除此之外,非常易于使用,您可以设置并行装载踏板的数量。
您可以在此处找到它
Well I was just typing the same solution...
to Load in some specific order, you have to make it recursive.
You may try the loadermax library from greensock. Is rock solid, fast and lightweight.
Besides that very easy to use and you can set the ammount of parallel loading treads.
you can find it here
资产的加载速度可能比其他资产更快,所以这样的事情可能会有所帮助......
Assets might load faster than others, so something like this might help...
好吧,我想这可行 - 但如果有人想出一种方法来做到这一点,而无需等待每个先前的图像加载后再开始另一个加载,请告诉我!
Well, I suppose this works - but if anyone figures out a way to do this without waiting for each previous image to load before starting another load, please let me know!