Skip to main content
Known Participant
June 1, 2008
Question

Flash + Xml, simple rss feed

  • June 1, 2008
  • 4 replies
  • 559 views
So , here's the deal

I foud this tutorial how to make flash read xml file and display it in dynamic text box. So my plan is to make app that connects to online .xml, reads it and displays it in my dynamic tex box. Txt is solved, including filtering, and all I need to be happy is to be able to add images, from that same xml file. So whenever wanted text appears I would like a little image to appear (on the right), depending on text.

Code (xml)

Code for loading xml file

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest(" http://www.kirupa.com/net/files/sampleXML.xml"));

function LoadXML(e:Event):void {

xmlData = new XML(e.target.data);
trace(xmlData);

}


What should I change in xml file and what in as?

Thank you
This topic has been closed for replies.

4 replies

CotealiAuthor
Known Participant
June 2, 2008
Here's my progress

my xml:

<Books>
<Book ISBN="0553212419">
<title> text za gjuro 2 </title>
<author>01062008</author>
<a href=" http://www.gjuro2.hr/">Check it</a>
<img src="magna_carta_131.JPG" width="35" height="35" hspace="100" vspace="10"></img>
</Book>

<Book ISBN="0553212416">
<title> TEXT ZA aq </title>
<author>03062008</author>
</Book>

<Book ISBN="0553212417">
<title> TEXT ZA piranha </title>
<author>01062008</author>
<a href=" http://www.gjuro2.hr/">Check it</a>
<img src="magna_carta_131.JPG" width="35" height="35" hspace="100" vspace="10"></img>
</Book>
</Books>

3 different books.

I made a filter. Every author that has "01062008" Should be displayed. But my text box only prints the last one. Obviously first book was overwritten..Somebody knows the solution?
Damon Edwards
Inspiring
June 2, 2008
Ned is correct, you won't need the width and height of the image. Otherwise, looks like good xml.
Ned Murphy
Legend
June 1, 2008
It's possible, I mean it looks okay... try it and see... do it in stages to be sure you are getting the information out of the xml file for the images.

I am probably just one step ahead of you as far as that tutorial goes, in that I have used it to create something of my own... I'm otherwise new to xml interaction. But one thing that you may not need to have is the width and height information. I think, but can't be sure, that that information might be obtainable from the Loader object. It's worth looking into since it will save you some xml coding effort if so.
Ned Murphy
Legend
June 1, 2008
In the XML file you need to include the names of the images that go with each text piece.

For the AS end you need to utilize the Loader object and the addChild method in order to dynamically insert the externally stored images that are named in the XML file. Look for the "Loading display objects" section in the Flash help documentation... it has an example that should help.
CotealiAuthor
Known Participant
June 1, 2008
Thanx Ned for replying, I will try to do it, and come back with results. I assume xml with image should looks something like this