# \[flash CS4\] ActionScript - loading data by xml

**URL:** https://forum.kirupa.com/t/flash-cs4-actionscript-loading-data-by-xml/313554
**Category:** flash
**Created:** [September 2, 2010, 2:29pm UTC](https://forum.kirupa.com/t/flash-cs4-actionscript-loading-data-by-xml/313554 "2010-09-02T14:29:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rculshaw](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@rculshaw](https://forum.kirupa.com/u/rculshaw)
#### Post date: [September 2, 2010, 2:29pm UTC](https://forum.kirupa.com/t/flash-cs4-actionscript-loading-data-by-xml/313554/1 "2010-09-02T14:29:40Z")

</div>

Hi

I followed a tutorial about loading data into Flash using xml. Everything works perfectly but I would like to add hyper links to the images.

Any ideas?

I’m new to this and trying to work it out. I’m presuming I need to add:

this.ref[" …something here… "+i].getURL(subnodes[2].firstChild.toString())

but its out of my zone at the moment.

Here is the ActionScript

* * *

//Create the XML Object  
myXML = new XML()  
myXML.ignoreWhite = true  
//Load XML file  
myXML.load(“anastasio.xml”)  
//Make a reference to current timeline  
myXML.ref = this  
// Parse XML and fetch  
myXML.onLoad = function(succes){  
if(succes){  
var root = this.firstChild  
nodes = root.childNodes  
for(var i=0; i\<nodes.length; i++) {  
this.ref[“Title\_txt”+i].text = nodes\*.attributes.name  
subnodes = nodes\*.childNodes  
this.ref[“Comments\_txt”+i].text = subnodes[0].firstChild.toString()  
this.ref[“holder\_mc”+i].loadMovie(subnodes[1].firstChild.toString())

```
    }
} else trace("Error loading XML document")

```

}  
stop()

* * *

and the xml

* * *

\<?xml version=“1.0” encoding=“UTF-8”?\>  
\<!DOCTYPE data[  
\<!ELEMENT title (comments, image)\>  
\<!ATTLIST title name CDATA #REQUIRED\>  
\<!ELEMENT comments (#PCDATA)\>  
\<!ELEMENT image (#PCDATA)\>  
]\>  
\<data\>

```
&lt;title name="Whats New"&gt;
    &lt;comments&gt;the summer is here and so are our lightest summer dresses...
    &lt;/comments&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;Photo Shoot &#13; movie
    &lt;/comments&gt;
    &lt;image&gt;an1.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;Jersey bling &#13; dress, brown
    &lt;/comments&gt;
    &lt;image&gt;an2.jpg &lt;/image&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;Bubble dress, smudge rose and hot flowerk
    &lt;/comments&gt;
    &lt;image&gt;an3.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name="Our lookbook"&gt;
    &lt;comments&gt;View this seaons look book
    &lt;/comments&gt;
    &lt;image&gt;an4.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;Send us your photos
    &lt;/comments&gt;
    &lt;image&gt;an5.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;Ying yang dress, hot pink
    &lt;/comments&gt;
    &lt;image&gt;an6.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name=""&gt;
    &lt;comments&gt;New yorker playsuit, shell pink
    &lt;/comments&gt;
    &lt;image&gt;an7.jpg&lt;/image&gt;
&lt;/title&gt;
&lt;title name="Bridesmaid lookbook"&gt;
    &lt;comments&gt;Bridesmaid &#13; collection
    &lt;/comments&gt;
    &lt;image&gt;an8.jpg&lt;/image&gt;
&lt;/title&gt;

```

\</data\>
