2012-01-15 57 views
0

我正在嘗試製作一個應用程序,您可以在其中從您的計算機或URL加載圖像文件。我的計算機文件部分工作正常,但在嘗試從URL加載圖像時遇到問題。從動作腳本中的URL加載圖像3未完成

下面是代碼:

public function loadNetImage(): void { 
if (urlFile.text != "") 
{ 
    loader.addEventListener(Event.COMPLETE, loaderComplete); 
    loader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError); 
    loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, handleHttpStatus); 
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecurityError); 
    try { 
    var request:URLRequest = new URLRequest(urlFile.text); 
    loader.load(request); 
    } 
    catch (e:Error) 
    { 
    trace(e); 
    } 
} 
} 

問題:負載請求後,它不叫我的任何事件。沒有錯誤,沒有加載。你可以從這段代碼中看到我試圖查看是否有錯誤的一些內容。

urlFile.text是從我的flex textInput返回的字符串。我把一個硬編碼的字符串,而不是urlFile.text,並沒有奏效。我改成了一個URLLoader,而不是一個基本的Loader,並且這種工作(它完成了負載),但之後我無法進行圖像操作,我在其他帖子中看到Loader是正確的東西被使用。

任何幫助將不勝感激。這可能很小,但我現在對此感到沮喪。

回答

3
var loader:Loader = new Loader(); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _loader_completeHandler); 
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _loader_errorHandler); 

等等。

contentLoaderInfo(即flash.display.LoaderInfoLoader財產分派的事件。

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html#includeExamplesSummary

+0

Argghhhh!我不會告訴你我在這個特殊問題上浪費了多少時間。 :)謝謝,這完全解決了問題! – 2012-01-16 00:59:52