loader.close 出现问题
有人能解释一下为什么 loader.close 不起作用吗? 顺便说一句,我知道从服务器加载文件的事情。
for (var p:Number = 0; p < itemsOnPage; p++)
{
if (itterationStep != SqlRec.itemsArray.length)
{
thumbImgLoader = new Loader();
var imgName:String = SqlRec.itemsArray[itterationStep]["img"];
thumbImgLoader.load(new URLRequest(GetXMLprefs.thumbsPath + imgName));
thumbLoadersArray.push(thumbImgLoader);
...
}
}
/////
if (ItemsBuilder.thumbLoadersArray)
{
if(ItemsBuilder.thumbLoadersArray.length > 0)
{
for (var i:Number = 0; i < ItemsBuilder.thumbLoadersArray.length; i++)
{
try
{
var obj:Loader = new Loader();
obj = ItemsBuilder.thumbLoadersArray[i];
obj.close();
trace(">> "+obj.close);
}catch (err:Error)
{
trace(err)
}
}
ItemsBuilder.thumbLoadersArray.splice(0, ItemsBuilder.thumbLoadersArray.length);
}
}
Can anybody explain, why loader.close didn't work?
Btw i know about loading files from server thing.
for (var p:Number = 0; p < itemsOnPage; p++)
{
if (itterationStep != SqlRec.itemsArray.length)
{
thumbImgLoader = new Loader();
var imgName:String = SqlRec.itemsArray[itterationStep]["img"];
thumbImgLoader.load(new URLRequest(GetXMLprefs.thumbsPath + imgName));
thumbLoadersArray.push(thumbImgLoader);
...
}
}
/////
if (ItemsBuilder.thumbLoadersArray)
{
if(ItemsBuilder.thumbLoadersArray.length > 0)
{
for (var i:Number = 0; i < ItemsBuilder.thumbLoadersArray.length; i++)
{
try
{
var obj:Loader = new Loader();
obj = ItemsBuilder.thumbLoadersArray[i];
obj.close();
trace(">> "+obj.close);
}catch (err:Error)
{
trace(err)
}
}
ItemsBuilder.thumbLoadersArray.splice(0, ItemsBuilder.thumbLoadersArray.length);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你从痕迹中得到什么了吗?
Flash 对于一次可以同时执行的并发加载数量有一个内部限制。您正在循环加载 800 张图像,这意味着前 780 张左右的图像将被后 20 张左右的图像覆盖。我一次加载的最大数量约为 10 个(我认为 BulkLoader 有类似的东西) 。如果您想加载 800 张图像,请使用数组来跟踪加载的内容。类似于:
至于
close()
,它“取消 Loader 当前正在进行的 load() 方法操作实例。”如果Loader
中没有发生load()
,那么可能什么也不会发生。PS:在您的
try
语句中,您每次都会创建一个新的Loader
,然后再将其分配给其他内容。只需将其更改为Are you getting anything out of the trace?
Flash has an internal limit with how many simultaneous loads it can do at once. You're loading 800 images in a loop, which means that the first ~780 or so will be overridden by the last 20 or so. The max I ever load at once is around 10 (I think BulkLoader has something similar). If you want to load in 800 images, use the array to keep track of what's loading in. Something like:
As for
close()
, it "Cancels a load() method operation that is currently in progress for the Loader instance." If there's noload()
going on in theLoader
, then nothing's probably going to happen.P.S.: in your
try
statement, you're creating a newLoader
everytime, before assigning it to something else. Just change it to