加载大量图像
我有这段代码,在选择少量图像时效果很好。
public var fileReferenceList:FileReferenceList;
public function browseFiles(event:Event = null):void
{
fileReferenceList= new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT,onMultipleFileSelect);
fileReferenceList.browse("images");
}
private function onMultipleFileSelect(event:Event):void
{
fileReferenceList.removeEventListener(Event.SELECT,onMultipleFileSelect);
var fileList:Array = event.target.fileList;
trace(fileList[0].name);
}
但是,当选择大量图像(1000+)时,调度 SELECT 事件时 fileList 尚未初始化。 有没有办法等待 fileList 初始化?
I have this code which works fine when selecting a small number of images.
public var fileReferenceList:FileReferenceList;
public function browseFiles(event:Event = null):void
{
fileReferenceList= new FileReferenceList();
fileReferenceList.addEventListener(Event.SELECT,onMultipleFileSelect);
fileReferenceList.browse("images");
}
private function onMultipleFileSelect(event:Event):void
{
fileReferenceList.removeEventListener(Event.SELECT,onMultipleFileSelect);
var fileList:Array = event.target.fileList;
trace(fileList[0].name);
}
However, when selecting a large number of images (1000+), the fileList isn't initialized yet when the SELECT event is dispatched.
Is there a way to wait for the fileList to be initialized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呼男孩。我认为在选择那么多文件时你永远不会获得你想要的性能,但一个可能的解决方案是检查 fileList 是否为空,如果是,则调用一个函数,该函数将对 fileList 的引用作为使用 callLater 的参数。在该方法中,检查它是否仍然为 null,然后使用 callLater 再次调用该函数。对此没有任何保证。它可能不起作用,因为 FileReferenceList 沙箱要求处理 UI 事件处理程序中的内容。祝你好运。
Hoo boy. I don't think you will ever get the kind of performance you would like when selecting that many files, but a possible solution would be to check if fileList is null and if it is, call a function that takes the reference to your fileList as a parameter using callLater. In that method, check if it is still null, then call the function again using callLater. No guarantees on this one. It might not work because of the FileReferenceList sandbox requirements of dealing with stuff in UI event handlers. Best of luck.