Skip to main content
Kristtee
Known Participant
October 10, 2009
Answered

as3 xml trouble

  • October 10, 2009
  • 1 reply
  • 1753 views

hi there

as a newbee...it is not easy at all. somehow i manage to put together my app. but in the end - jezzz what a troubles. take a look and help me please.

i want the data from xml to load.

thanks in advance

krs

This topic has been closed for replies.
Correct answer CaioToOn!

Hi, Kristee.

There is three mistake:

     1st) You're duplicating the "loader" and "request" variables at

// load text var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("lorem.txt"); loader.load(request); loader.addEventListener(Event.COMPLETE, loadcomplete); function loadcomplete(event:Event) {     // move loaded text to text field     myTxt.text = loader.data;     // Set myTxt as target for scroll bar.     mySb.scrollTarget = myTxt; }

   You need a different variable name, so, change it to "textLoader" and "textRequest", for example, in all the 6 occurrences.

     2nd) The correct variable name is "dataXML", not "teamXML".

 var myDP:DataProvider = new DataProvider(teamXML); 

     3rd) In your XML, when closing the root node <data>, you misstyped it to </date>.

I hope this help.

Regards,

CaioToOn!

1 reply

CaioToOn!Correct answer
Inspiring
October 10, 2009

Hi, Kristee.

There is three mistake:

     1st) You're duplicating the "loader" and "request" variables at

// load text var loader:URLLoader = new URLLoader(); var request:URLRequest = new URLRequest("lorem.txt"); loader.load(request); loader.addEventListener(Event.COMPLETE, loadcomplete); function loadcomplete(event:Event) {     // move loaded text to text field     myTxt.text = loader.data;     // Set myTxt as target for scroll bar.     mySb.scrollTarget = myTxt; }

   You need a different variable name, so, change it to "textLoader" and "textRequest", for example, in all the 6 occurrences.

     2nd) The correct variable name is "dataXML", not "teamXML".

 var myDP:DataProvider = new DataProvider(teamXML); 

     3rd) In your XML, when closing the root node <data>, you misstyped it to </date>.

I hope this help.

Regards,

CaioToOn!

Kristtee
KristteeAuthor
Known Participant
October 12, 2009

Hi

Thank you - CaioToOn. You are The Man. As you have helped me, i did all the corrections and it is just cool. There  is one more question. I wonder whether it is possible to bind the image and textfield data from the same xml file. Presently it is not from the xml data. Can you guide me through..Please. Please.

I really appreciate your time. Thank you again.

regards

Kristtee

October 12, 2009

Hi,

Try this code:

The data from img and the desc from the XML

var img_name:Array = new Array();

var desc:Array = new Array();

for (var i1:int=0; i1<dataXML.item.length(); i1++) {

img_name.push(dataXML.item.img[i1]);

desc.push(dataXML.item.desc[i1]);

}

trace(img_name+":img_name");

trace(desc+":desc");

Saransoft