2013-11-14 333 views
0

我試圖加載從我的XML文件中的一些圖片(圖片被URL:■從其他網站)類型錯誤:Errpr#1010:一個術語是不確定的,沒有屬性AS3

至極我已經成功做(ATLEAST使其可見)

現在,我試圖讓我的標籤的所有內容,並顯示在我的文本框(的errorMessage)

但不知何故,我甚至無法追查任何超出我的xmlLoadedImages函數,我得到這個錯誤。

TypeError: Errpr #1010: A term is undefined and has no properties AS3

import flash.net.URLRequest; 
import flash.net.URLLoader; 
import flash.events.Event; 
import flash.display.Loader; 
import flash.display.LoaderInfo; 
import fl.containers.UILoader; 
import flash.system.LoaderContext; 


var xmlRequest:URLRequest = new URLRequest("Vehicles.xml"); 
var xmlLoader:URLLoader = new URLLoader(xmlRequest); 
var imgData:XML; 

var imageLoader:Loader; 
var titleLoader:Loader; 
var raw_image:String; 
var raw_text:String; 

var title:String; 
var message:String; 
var imgNum:Number = 0;  


xmlLoader.addEventListener(Event.COMPLETE, xmlLoadedImages); 
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, wrong); 


function wrong(evt:IOErrorEvent):void{ 
    errorMessage.text="Something's wrong."; 
} 


function xmlLoadedImages(event:Event):void 
{ 

    var A:Array=[image1_mc,image2_mc,image3_mc,image4_mc]; 

    imgData = new XML(event.target.data); 

    var imageLength:int = imgData.Vehicle.Pictures.children().length(); 
    //trace(imageLength); 
    for (var i: int = 0; i < imageLength; i++) 
    { 
     raw_image = imgData.Vehicle.Pictures.Url[i]; 
     imageLoader = new Loader; 
     var context:LoaderContext = new LoaderContext(); 
     context.applicationDomain = ApplicationDomain.currentDomain; 
     imageLoader.load(new URLRequest(raw_image), context); 
     A[i].addChild(imageLoader); 
     A[i].height = 150; 
     A[i].width = 150; 


    } 
    message = imgData.Vehicle.EquipmentList; 
    trace(message); 

} 
function xmlLoadedText(event:Event):void 
{ 
    var xmlLength:int = imgData.Vehicle.EquipmentList.children().length(); 
    //trace(xmlLength); 

    for(var b:int = 0; b < xmlLength; b++) 
    { 
     trace(imgData.Vehicle.EquipmentList.Equipment[b]) 
     var B:Array = [imgData.Vehicle.EquipmentList.Equipment[b]]; 
     trace(B); 
     errorMessage.text = B.toString(); 
    } 
} 

任何人都知道這個問題可能是什麼?

這裏是我的一些XML,大部分是我使用的那些部分。

 <EquipmentList> 
     <Equipment>ABSBrakes</Equipment> 
     <Equipment>Airbags8</Equipment> 
     <Equipment>Alarm</Equipment> 
     <Equipment>Alloy16</Equipment> 
     <Equipment>AutomaticClimateControl</Equipment> 
     <Equipment>AutomaticGeartronic</Equipment> 
     <Equipment>CruiseControl</Equipment> 
     <Equipment>CupHolder</Equipment> 
     <Equipment>ESP</Equipment> 
     <Equipment>ExternalThermometer</Equipment> 
     <Equipment>Immobilizer</Equipment> 
     <Equipment>LeatherSteeringWheel</Equipment> 
     <Equipment>LoweredSuspension</Equipment> 
     <Equipment>Navigation</Equipment> 
     <Equipment>NonSmoker</Equipment> 
     <Equipment>OneOwner</Equipment> 
     <Equipment>PoweredMirrorsHeated</Equipment> 
     <Equipment>RemoteCentralLocking</Equipment> 
     <Equipment>SeatHeater</Equipment> 
     <Equipment>ServiceOK</Equipment> 
     <Equipment>TaintedWindowsRear</Equipment> 
     <Equipment>TripComputer</Equipment> 
     <Equipment>WhiteTurningSignal</Equipment> 
    </EquipmentList> 
    <PictureCount>5</PictureCount> 
    <Pictures> 
     <Url>http://images.bilinfo.dk/images/44700008.jpg</Url> 
     <Url>http://images.bilinfo.dk/images/44700008_1.jpg</Url> 
     <Url>http://images.bilinfo.dk/images/44700008_2.jpg</Url> 
     <Url>http://images.bilinfo.dk/images/44700008_3.jpg</Url> 
     <Url>http://images.bilinfo.dk/images/44700008_4.jpg</Url> 
    </Pictures> 
+0

你得到一個線數字與你的錯誤?你能發佈一些你的xml嗎? – bwroga

+0

所以我已經把我使用的XML的部分。並沒有我沒有得到任何行號:(這就是爲什麼很難找出未定義的屬性是 –

+0

我的理解是否正確,該錯誤發生在xmlLoadImages方法? –

回答

0

我找到了答案。我哈德只有四個UILoaders(改成了UILoaders)而

for (var i: int = 0; i < imageLength; i++) 

試圖把5個元素(在我的XML五行),而這也正是最後的財產來源不明去

相關問題