Kirupa’s xml-flash slideshow works fine when it is being implemented on its own timeline.
I made a sample project and externally loaded this slideshow by calling it thru loadMovie(). In the file that I’ve provided, you will see that once you’ve clicked the loadMovie button the slideshow is being loaded on the left side of the stage with no error.
The problems arises when you unloads and loads the movie repeatedly. The slideshow’s transition effects jumps too fast from one image to another, as if the image sequencing is gone. And if you test and try to click the buttons for more load and unload operations you will end up seeing the [COLOR=Red]“Error opening url - file://undefined”[/COLOR] - as if the movie cannot keep up with the phasing of button’s events!:sen:
**[COLOR=Blue]Here’s the codes:
In XML:
[/COLOR]**
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>pic1.jpg</image>
<caption>Picture 1</caption>
</pic>
<pic>
<image>pic2.jpg</image>
<caption>Picture 2</caption>
</pic>
<pic>
<image>pic3.jpg</image>
<caption>Picture 3</caption>
</pic>
<pic>
<image>pic4.jpg</image>
<caption>Picture 4</caption>
</pic>
</images>
**[COLOR=Blue]
Inside .FLA:
Main Movie:
[/COLOR]**
bigRed_btn._visible = false;
txtMovieNotLoaded._visible = false;
//Load Movie
bigBlue_btn.onRelease = function () {
loadMovie("slideshow.swf", slideshowHolder_mc);
bigBlue_btn._visible = false;
bigRed_btn._visible = true;
txtMovieNotLoaded._visible = false;
}
//Unload Movie
bigRed_btn.onRelease = function () {
unloadMovie(slideshowHolder_mc);
bigRed_btn._visible = false;
bigBlue_btn._visible = true;
txtMovieNotLoaded._visible = true;
}
**[COLOR=Blue]
In “Slideshow.swf”:
[/COLOR]**
**[COLOR=Blue] var delay:Number = 3000;
//-----------------------[/COLOR]**
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData.load("images.xml");
// ///////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_mc.onRelease = function() {
prevImage();
};
next_mc.onRelease = function() {
nextImage();
};
// ///////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preloadBar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
var myInterval;
function nextImage() {
p++;
p %= image.length;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
clearInterval(myInterval);
if (playing) {
slideshow();
}
}
}
function prevImage() {
clearInterval(myInterval);
if (playing) {
slideshow();
}
if (p>0) {
p--;
} else {
p = image.length-1;
}
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
clearInterval(myInterval);
if (playing) {
slideshow();
}
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+"/"+total;
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
nextImage();
}
}
stop.tt.text = "STOP";
play.tt.text="PLAY"
playing = true
play.onPress = function(){
playing = true
nextImage()
}
play.onRelease =play.onReleaseOutside= function(){
this.gotoAndStop("_disabled")
this.enabled = false
}
stop.onPress = function(){
playing = false
play.enabled = true
clearInterval(myInterval)
}
**[COLOR=Red]
But it is better if you look for the attachment files -->[/COLOR]**