我正在尝试从我的 XML 文件中加载一些图片(这些图片是来自另一个站点的 URL:s)
我设法做到了(至少让它们可见)
现在我正在尝试获取标签中的所有元素并将它们显示在我的文本框中(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>