0

我是 actionscript 中该主题的初学者,但我有一个大的 xml 响应,如下所示,我不知道如何将其转换为一个类,那里有很多字段,我该如何正确构造它们?

<GCPResponse userLocale=”de_AT_7_1”&gt;
<Messages>
<PopUpMessages>
<Message no=”1” type=”game” name=”DONATION” key="detailKeyIfNecessary">
 ahhhdhhdhdhd
</Message>
</PopUpMessages>
<TickerMessages>
<Message no=”1” type=”game” name=”TTJP” key="detailKeyIfNecessary">
  fdfdfd
</Message>
<Message no=”2” type=”game” name=”LDJP”&gt;
 fffff
</Message>
</TickerMessages>
</Messages>
<Response currency=”EUR”&gt;
<BalanceCash>10000</BalanceCash>
<BalanceDonation>10000</BalanceDonation>
<DrawClosingTime>2013-04-12T23:20:50+01:00</DrawClosingTime>
<DrawOpeningTime>2013-04-10T12:00:00+01:00</DrawOpeningTime>
<Default maxDraws=”4” draws=”1” picks=”12” jokerPicks=”1”/>
<PickPrice gameName=”ttt” draw=”123” price=”60”/>

    </Response>
</GCPResponse>
4

1 回答 1

0

使用 URLLoader 加载外部 XML 文件,即:

import flash.net.URLLoader;

...

private var _loader:URLLoader = new URLLoader();
private var _xml:XML;
private var _XMLselection:XMLList;

...

_loader.load(new URLRequest("assets/commissionercontent.xml"));
_loader.addEventListener(Event.COMPLETE, xmlLoaded);
_loader.addEventListener(IOErrorEvent.IO_ERROR, xmlError);

private function xmlError(p_event:Event):void {
    trace("XML error - maybe do something graphical here?");
}

private function xmlLoaded(p_event:Event):void {
    _xml=new XML(p_event.target.data);
}

将 XML 作为 Flash XML 对象后,您可以进行选择,例如:

_XMLselection = _xml.GCPResponse.Fixtures;

检查 adobe 实时文档... http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html

于 2013-07-15T16:24:06.663 回答