Greetings.
I am loading some xml data into flash.
This data includes images, text and a url.
The application is a image rotator with text and a link.
I am wanting the text to animate, so I have a movie clip which contains the text fields. This clip has a number of frames and layers. If I have the dynamic text field on the first frame then the xml data loads into it fine, but if I have it beginning on any other frame but the first it doesnt work.
Can someone tell me how I can have the xml data populate the text fields in other places other than the first frame?
Thanks
Here is my code
Code:
delay = 8000;
// -----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
price = [];
currency = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
price[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
currency[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
// ///////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 11;
}
}
};
//Populate Textfields
function textPopulate() {
//this.textInfo.desc_txt.text = description[p];
//this.textInfo.txt_currency.text = currency[p];
//this.fareDetails.price.txt_currency.text = currency[p];
this.fareDetails.test.text = price[p];
//this.fareDetails.price.txt_price.text = price[p];
//this.fareDetails.fareName.txt_main.text = description[p];
}
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
textPopulate();
picture_num();
slideshow();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
textPopulate();
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
textPopulate();
picture_num();
tweenImages();
slideshow();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function slideshow() {
playFareDetails();
tweenImages();
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}
}
//slide images up
function tweenImages(easeType) {
var begin = 22.6;
var end = 7.8;
var time = 51;
var mc = picture;
ballTween = new mx.transitions.Tween(mc, "_y", easeType, begin, end, time);
}
function playFareDetails(){
this.fareDetails.play("begin");
//trace("fare details fired");
}