I have an .xml file which is one I downloaded and modified.
I’m trying to get flash to read the Title and display it in txt field inside a movie clip.
Here is my xml code:
<?xml version="1.0" encoding="UTF-8"?>
<gallery path="Portfolio: Music/">
<image title="1 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image1.jpg" thumb="music humbs 1.jpg" heading= "music"/>
<image title="2 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image2.jpg" thumb="music humbs 2.jpg"/>
<image title="3 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image3.jpg" thumb="music humbs 3.jpg"/>
<image title="4 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image4.jpg" thumb="music humbs 4.jpg"/>
<image title="5 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image5.jpg" thumb="music humbs 5.jpg"/>
<image title="6 - Thomas Spencer-Wortley Concert 28-11-2008" source="music\image6.jpg" thumb="music humbs 6.jpg"/>
</gallery>
And here is my actionscript which currently loads the ‘image title’ and the source image to stage:
spacing = 16;
containerMC._alpha = 0;
var pArray = new Array();
var tArray = new Array();
var cur = 0;
MovieClip.prototype.loadPic = function(pic) {
cur = pic;
containerMC._alpha = 0;
this.loadMovie(pArray[pic]);
this._parent.onEnterFrame = function() {
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
bar._visible = 1;
per = Math.round((l/t)*100);
if (t != 0 && Math.round(l/t) == 1 && containerMC._height != 0) {
// Code for the border width at the bottom of the movie (the +30 part)
var w = containerMC._width+spacing, h = containerMC._height+spacing+30;
border.resizeMe(w, h);
bar._visible = 0;
picinfo.info.text = tArray[pic];
delete this.onEnterFrame;
} else {
//gives the bar a max width 100
bar._width = per;
// Turns photo caption (picinfo) into a % loader whilst loading
picinfo.info.text = per+" % loaded";
//Attempt to read title from xml
gallerytitle.title.text = header;
if(picinfo.info.text == "NaN") {
picinfo.info.text = "0";
}
}
};
};
MovieClip.prototype.resizeMe = function(w, h) {
var speed = 3;
containerMC._alpha = 0;
this.onEnterFrame = function() {
this._width += (w-this._width)/speed;
this._height += (h-this._height)/speed;
// Code to position the caption to the relative bottom left of the movie clip
//prev_btn._x = nav._x-5;
//next_btn._x = nav._x+this._width-150;
//next_btn._y = prev_btn._y=this._y-this._height/2;
picinfo._y = this._y+this._height/2+spacing-40;
picinfo._x = this._x-this._width/2+spacing/2;
//finish
if (Math.abs(this._width-w)<1) {
this._width = w;
this._height = h;
containerMC._x = this._x-this._width/2+spacing/2;
containerMC._y = this._y-this._height/2+spacing/2;
// Speed of fade in
containerMC._alpha += 5;
if (containerMC._alpha>90) {
containerMC._alpha = 100;
delete this.onEnterFrame;
}
}
};
};
var gallery_xml = new XML();
gallery_xml.ignoreWhite = true;
gallery_xml.onLoad = function(success) {
if (success) {
var gallery = this.firstChild;
for (var i = 0; i<gallery.childNodes.length; i++) {
tArray.push(gallery.childNodes*.attributes.title);
pArray.push(gallery.childNodes*.attributes.source);
}
//loading first picture
containerMC.loadPic(0);
} else {
title_txt.text = "Error!";
}
};
gallery_xml.load("gallery.xml");
prev_btn.onRelease = function() {
cur--;
if (cur<0) {
containerMC.loadPic(pArray.length-1);
} else {
containerMC.loadPic(cur);
}
};
next_btn.onRelease = function() {
cur++;
if (cur>pArray.length-1) {
containerMC.loadPic(0);
} else {
containerMC.loadPic(cur);
}
};
Please can someone point me in the right direction.
Any help would be appreciated.
Cheers