Solved

loading 6 images,titles, urls from xml and displaying them

Posted on 2006-07-10
4
139 Views
Last Modified: 2010-04-03
i'm new to actionscript, i'm interested in loading some data from my xml file,
and displaying it...
what should i do?

i have an xml file with 6 items:

<item>
<image>http://www.someurl.com/image1.jpg</image>
<title>Some title</title>
<url>http://www.someurl.com</url>
</item>


i want to show them as images, title, and make them link to a url
do i have to create the clips manually, or with actionscript, thanks!
0
Comment
Question by:svsvsv
4 Comments
 
LVL 14

Accepted Solution

by:
trigger-happy earned 250 total points
ID: 17072780
The recommended way to handle xml is by actionscript. The thing is that handling xml files with actionscript can be tedious and tricky but the rewards of flexibility and control outweigh the troubles. I would suggest you look into some tutorials on how to read xml files in flash.

The trick with parsing that kind of xml file would be to loop through all the item elements and grabbing the data you need. This is normally the parsing part or what i call, grab the data. The next part would be to use that data in the way you want. This phase would normally involve loading the images into the respective movie clips, putting the title inside the text box then make use of the link data for the getURL actions.

--trigger-happy
0
 
LVL 3

Assisted Solution

by:BishopNeo
BishopNeo earned 250 total points
ID: 17073606
You can use the XML Class to extrapolate the data you need.  Assume your file is called data.xml (for sake of this discussion), you could do:

var RootNode:XMLNode;
var dXML:XML = new XML();
dXML.ignoreWhite = true;
dXML.onLoad = parseXML;
dXML.load("data.xml");
function parseXML(success:Boolean) {
      if (success) {
            RootNode = this.firstChild;
            for (x:Number = 0; x < RootNode.childNodes.length; x++) {
                  trace(RootNode.childNodes[x].firstChild.nodeValue);
            }
      }
}

Once in the for loop you can put the data into an array if you like and retreive it later.  This is just a starting point, they is a LOT more you can do with the XML data.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question