[英]Image not loading while url is retrieved correctly as3
我正在使用一個首先從deviant-art獲取xml提要並提取圖像形式的url的應用程序,然后將其顯示在加載程序中,但是當我跟蹤它時,它顯示檢索到的url,但加載程序未顯示圖像。 我只寫了必要的代碼
var contentLoader:Loader = new Loader();
contentLoader.x = 10;
contentLoader.y = 100;
contentLoader.width = 280;
contentLoader.height = 260;
addChild(contentLoader);
function requestCompleted(e:Event):void
{
var imageData:XML = new XML(e.target.data);
var media:Namespace = imageData.namespace('media');
trace(imageData.channel.item[0].media::content.@url);
var image:URLRequest = new URLRequest(imageData.channel.item[0].media::content.@url);
contentLoader.load(image);
}
由於trace語句,它在輸出窗口中顯示URL,但未在加載器中顯示URL
清除緩存后,嘗試將trace語句中的URL復制並粘貼到瀏覽器中,看看它是否有效。 該URL可能有效,但是圖像本身可能丟失
嘗試添加事件偵聽器,以便contentLoader可以偵聽
contentLoader.addEventListener(Event.COMPLETE,onLoaderComplete);
private function onLoaderComplete():void
{
contentLoader.load(image);
}
urlRequest應該花費一些時間來加載,因此添加此complete事件,並在該方法中將圖像加載到加載器中,並將圖像變量設置為Global。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.