Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex AdobeAIR-如何捕获图像加载完成的事件?_Apache Flex_Actionscript 3_Image_Air_Onload Event - Fatal编程技术网

Apache flex AdobeAIR-如何捕获图像加载完成的事件?

Apache flex AdobeAIR-如何捕获图像加载完成的事件?,apache-flex,actionscript-3,image,air,onload-event,Apache Flex,Actionscript 3,Image,Air,Onload Event,我的代码的核心如下: var img:Image = new Image; img.source = 'http://..........'; img.autoLoad = true; img.cachePolicy = 'on'; img.addEventListener(Event.COMPLETE, function(event:Event):void { trace('Loaded!', img.source); }); img.addEventList

我的代码的核心如下:

var img:Image = new Image;  
img.source = 'http://..........';  
img.autoLoad = true;  
img.cachePolicy = 'on';

img.addEventListener(Event.COMPLETE, function(event:Event):void {  
    trace('Loaded!', img.source);  
});  
img.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(event:Event):void {  
    trace('Error!', img.source);  
});  
img.addEventListener(IOErrorEvent.IO_ERROR, function(event:Event):void {  
    trace('Error!', img.source);  
});  
我发现,对于某些图像,完整事件不会发生。
如何在没有信号泄漏的情况下捕获完整事件?

当您要加载映像(甚至另一个swf)时,要使用的类是Loader。一个简单的例子:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, handlerFunction);
loader.load(new URLRequest("http://somewhere/image.png"));
唯一棘手的事情是与加载相关的事件由
loader.contentLoaderInfo
对象调度,而不是
loader
对象

以及始终方便的文档:

谢谢您的帮助。我发现问题出在代码的另一部分。我检查了这两种样式是否都能正常工作——“img.src=…”和“使用加载器”。