AS3 LoaderMax:将图片加载到数组中?
我有以下问题。我想使用 LoaderMax 将 3 张图片加载到舞台上。它们的路径存储在一个数组(url)中,最后我想将它们的所有 displayList 对象放在一个名为 pictures 的新数组中。
这是我的代码:
var urls:Array = new Array("../data/bild1.jpg","../data/bild2.jpg", "../data/bild3.jpg");
for(var i:Number = 0; i< urls.length; i++){
var loadery = new ImageLoader(urls[i]);
loadery.load()
pictures[i] = loadery;
addChild(pictures[i]);
pictures[i].alpha = .5;
我希望它们存储在数组“图片”中,因为我想稍后用它们做几件事,如果它们存储在数组中,这些事情会更简单。
因此,Flash 收到 pictures[i] = loadery;
的编译器错误,它显示 TypeError: Error #1009: Cannot access a property or method of a null object reference.
所以我怎样才能轻松做到这一点?
感谢您的帮助。
I have the following problem. I wanna load 3 pictures to the stage using LoaderMax. Their path is stored in an array (urls), and finally I wanna have all their displayList objects in a new array called pictures.
here's my code:
var urls:Array = new Array("../data/bild1.jpg","../data/bild2.jpg", "../data/bild3.jpg");
for(var i:Number = 0; i< urls.length; i++){
var loadery = new ImageLoader(urls[i]);
loadery.load()
pictures[i] = loadery;
addChild(pictures[i]);
pictures[i].alpha = .5;
I want them to be stored in the array "pictures", because I wanna do later several things with them, which are more simple, if they are stored in an array.
So, Flash gets an compiler error for pictures[i] = loadery;
It says TypeError: Error #1009: Cannot access a property or method of a null object reference.
So how can I do this easily?
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ImageLoader
不会同步加载内容,要获取加载的图像实例,您必须监听onImageLoad
事件:要加载多个图像,您可以使用 LoaderMax 对象,它将对您的加载进行排队,要确切了解如何使用 ImageLoader 类,请阅读它的文档
ImageLoader
doesn't load content synchronuosly, to get loaded image instance you have to listen toonImageLoad
event:To load several images you can use LoaderMax object which will queue your loadings, to see exactly how use ImageLoader class read it's documentation