Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML linking

Status
Not open for further replies.

netliance

Technical User
Jan 25, 2005
2
US
Whats up...

The boss told me that I need to create a flash movie that can handle multiple images from an outside document...

So im usinG XML so that we can easily add and subtract images from it when the client deems neccessary. Unforunately, I've never worked with XML so I'm having a hard time finding the right information.

What I have so far is this:
<pic>
<image> <caption>The Dome</caption>
</pic>
<pic>
<image> <caption>Structure</caption>
</pic>

I dont really need the caption part, but what I do need and am having a hard time finding, is a way to link this image to a different html document.

If someone can give me a hand, I'd really appreciate it!

Thanks again!
 
You can use XSL to transform the XML to an appropriate HTML format. Its not clear from your post exactly what you're trying to do. You want to get the XML into a flash movie or just HTML?

Jon
 
Jon,
Thanks for the reply.... I've got the images loading from an XML file along with some captions. What I need to do is make the image a clickable link, from inside the flash file, the .swf, and i need to pull the link from an xml file so i can keep the image with the appropiate link.

someone had mentioned this actionscript method:

picture.onRelease = function(){
getURL(description[p],"_blank");
}

wheres the description is the link... so when I get to work, I need to test that out... but as of right now, that description feeds out to a dynamic text clip.

Thanks for the time!
 
Just a thought, but why you using XML? Also, this question would probably be more appropriate for the flash forum.

Anyway, if you wanna do it, make sure your XML is valid. It can only have one top level element. So you need:

Code:
 <piclinks>
  <pic>
    <image>[URL unfurl="true"]http://www.kirupa.com/developer/mx2004/pg/dome.jpg</image>[/URL]
    <caption>The Dome</caption>
  </pic>
  <pic>
    <image>[URL unfurl="true"]http://www.kirupa.com/developer/mx2004/pg/structure.jpg</image>[/URL]
    <caption>Structure</caption>
  </pic>
</piclinks>
Then you need to load the XML into a Flash XML variable:

Code:
// create a new Flash XML object
var piclinks:XML = new XML();

// load the XML into the piclinks object
piclinks.load("piclinks.xml");
Now you need to use the onload method to assign the links, something along the lines of:

Code:
// After loading is complete, assign links
piclinks.onLoad = function(success) {
  // Get the first URL from the XML object
  var picURL:String = piclinks.childNodes[1].firstChild.nodeValue;

  // Assign the URL to the pic
  picture.onRelease = function(){
     getURL(picURL, "_blank");
  }
};
Hope this helps.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top