Expand my Community achievements bar.

XML loader in ActionScript define failure

Avatar

Former Community Member
I used the XML class in the <mx:Script> tag.

I defined a URLLoader to load an external XML file. But the
system return a undefined object on it.



My script are here:



<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">

<mx:Script>

<![CDATA[

import mx.core.EventPriority;



var MyXML:XML = new XML();

var MyRequest:URLRequest = new URLRequest("
http://sweb.cityu.edu.hk/50685791/Adv_trialPosts.xml");

var MyLoader:URLLoader = new URLLoader(MyRequest);

MyLoader.addEventListener(Event.COMPLETE, onComplete );



private function onComplete(event:Event):void {

MyXML = XML(MyLoader.data);

}



]]>

</mx:Script>

</mx:Application>







The system returns two errors:

1120:Access of undefined property MyLoader.

1120:Access of undefined property onComplete



Moreover, I think the MyXML is also failed to defined.



What can I do???



thx!!!
0 Replies