我正在尝试从我的XML文件中加载一些图片(图片是来自其他网站的网址)
我设法做到了(Atleast让它们可见)
现在我正在尝试获取标签中的所有元素并在我的文本框中显示它们(errorMessage)
但不知怎的,我甚至无法追踪xmlLoadedImages函数以外的任何内容,我收到此错误。
TypeError:Errpr#1010:术语未定义且没有属性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 :(得分:0)
我找到了答案。我只有四个UILoader(改为UILoaders)和
for (var i: int = 0; i < imageLength; i++)
尝试输入5个元素(我的XML中有5个元素),这是最后一个未识别的属性去了