0

I'm beginner in that topic in actionscript, but I have a large xml response like the following and I don't know how to convert it to a class, there are a lot of fields there, how do I structure them correctly ?

<GCPResponse userLocale=”de_AT_7_1”>
<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”>
 fffff
</Message>
</TickerMessages>
</Messages>
<Response currency=”EUR”>
<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>
Andre
  • 363
  • 3
  • 15
  • Maybe this link [Deserialize XML to custom Class in Flex?](http://stackoverflow.com/questions/1804441/deserialize-xml-to-custom-class-in-flex) will be useful. Possible duplicate!. – Gaston Flores Jul 15 '13 at 20:44

1 Answers1

0

Use URLLoader to load an external XML file, ie:

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);
}

Once you have the XML as a Flash XML object, you can make selections, such as:

_XMLselection = _xml.GCPResponse.Fixtures;

Check the adobe live docs... http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/XML.html

moosefetcher
  • 1,841
  • 2
  • 23
  • 39