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/
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<this.firstChild.childNodes.length;x++)
{
listArray.push(x);
}
for(x=0;x<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<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<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);
}