actionscript 3 - converting an xml to an object -


i'm beginner in topic in actionscript, have large xml response following , don't know how convert class, there lot of fields there, how 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> 

use urlloader load 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 graphical here?"); }  private function xmlloaded(p_event:event):void {     _xml=new xml(p_event.target.data); } 

once have xml flash xml object, can make selections, such as:

_xmlselection = _xml.gcpresponse.fixtures; 

check adobe live docs... http://help.adobe.com/en_us/flashplatform/reference/actionscript/3/xml.html


Comments