# Load images and assign URL/PDF downlaod via XML

**URL:** <https://forum.kirupa.com/t/load-images-and-assign-url-pdf-downlaod-via-xml/199240>\
**Category:** flash\
**Created:** [August 31, 2006, 9:24pm UTC](https://forum.kirupa.com/t/load-images-and-assign-url-pdf-downlaod-via-xml/199240 "2006-08-31T21:24:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![checkone](https://avatars.discourse-cdn.com/v4/letter/c/c4cdca/32.png) [@checkone](https://forum.kirupa.com/u/checkone)\
**Post date:** [August 31, 2006, 9:24pm UTC](https://forum.kirupa.com/t/load-images-and-assign-url-pdf-downlaod-via-xml/199240/1 "2006-08-31T21:24:21Z")

</div>

I’ve had some help building this image viewer in flash. it uses xml to manage the images and caption text.

The problem i’m having is I need to make the (download pdf) a working link, at the moment it is just text. the guy that helped me is on holiday so I’m stuck!

you can see it working at: [http://www.danielatkinson.com/test/](http://www.danielatkinson.com/test/)

thanks.

the xml file is as follows…(x20 lines)  
\<images\>  
\<image img=“images/large/test\_1.jpg” thumb=“images/sml/test\_t1.jpg” caption=“download pdf”/\>

the action script in frame 1 looks like this…

stop();  
var stageWidth:Number = Stage.width+320;  
var preloadNum = Math.round(Math.floor(stageWidth/84))  
var loadArray:Array = new Array()  
var listArray:Array = new Array()  
var numImages:Number  
var menuWidth:Number  
var init:Boolean = false;  
var currentLoad:Number = 0  
\_global.selectDisabled = true;

this.createEmptyMovieClip(“images”,10);  
images.\_y = 132;  
images.\_x = 335;  
this.createEmptyMovieClip(“menu”,20);  
menu.\_y = 564;  
menu.\_x = 0;  
menu.createEmptyMovieClip(“menu1”,1);  
menu.menu1.\_x = 593;  
menu.createEmptyMovieClip(“menu2”,2);

myXML = new XML();  
myXML.ignoreWhite = true;  
myXML.onLoad = function(success)  
{  
if(success)  
{  
var xPos = 0;  
numImages = this.firstChild.childNodes.length;  
menuWidth = numImages\*84;

```
    for(x=0;x&lt;this.firstChild.childNodes.length;x++)
    {
        listArray.push(x);

    }
    
    for(x=0;x&lt;this.firstChild.childNodes.length;x++)
    {
        if(x%2)
        {
            loadArray.push(listArray[listArray.length-1]);
            listArray.pop();
        }
        else
        {
            loadArray.push(listArray[0]);
            listArray.splice(0,1)
        }
    }
     
    for(x=0;x&lt;this.firstChild.childNodes.length;x++)
    {

        menu.menu1.attachMovie("thumb","thumb"+x,x+1);
        menu.menu1["thumb"+x]._alpha = 0;
        menu.menu1["thumb"+x]._x = xPos;
        menu.menu1["thumb"+x].iPos = x;
        xPos += 84;
    }
    
    
    menu.menu2._x = 593 - menuWidth
    xPos = 0;
    
    for(x=0;x&lt;this.firstChild.childNodes.length;x++)
    {
        menu.menu2.attachMovie("thumb","thumb"+x,x+1);
        menu.menu2["thumb"+x]._alpha = 0;
        menu.menu2["thumb"+x]._x = xPos;
        menu.menu2["thumb"+x].iPos = x;
        xPos += 84;
    }
    
    
    loadImage()
}

```

}

myXML.load(‘test.xml’);

var myImageLoader = new MovieClipLoader ();  
var myThumbLoader = new MovieClipLoader ();

myImageLoader.onLoadComplete = function (targetMC)  
{  
myThumbLoader.loadClip(myXML.firstChild.childNodes[loadArray[currentLoad]].attributes.thumb,menu.menu1[“thumb”+loadArray[currentLoad]].image);  
myThumbLoader.loadClip(myXML.firstChild.childNodes[loadArray[currentLoad]].attributes.thumb,menu.menu2[“thumb”+loadArray[currentLoad]].image);  
targetMC.\_parent.gotoAndStop(2)  
currentLoad++  
if(currentLoad \< numImages) loadImage()

}

myThumbLoader.onLoadComplete = function (targetMC)  
{  
//targetMC.\_parent.gotoAndStop(2);  
if ((currentLoad+1) == preloadNum || (currentLoad+1) == numImages) {  
if (!init) {  
gotoAndStop(‘main’)  
}  
}

}

function loadImage()  
{  
var perc = -690+((currentLoad+1)/preloadNum)\*614;  
loader.bar.\_x = perc  
images.attachMovie(“mainImage”,“image”+loadArray[currentLoad],currentLoad+1);  
images[“image”+loadArray[currentLoad]].\_x = 2000;  
if(myXML.firstChild.childNodes[loadArray[currentLoad]].attributes.caption)  
{  
images[“image”+loadArray[currentLoad]].captionText.text = myXML.firstChild.childNodes[loadArray[currentLoad]].attributes.caption;  
}  
myImageLoader.loadClip(myXML.firstChild.childNodes[loadArray[currentLoad]].attributes.img,images[“image”+loadArray[currentLoad]].imageHolder);  
}
