Hi people
I am creating a dynamic xml gallery (with slideshow) with navigation buttons (next & back buttons)
I have included a dropdown menu for users to navigate to and fro
Somehow I managed to make the dropdown links work
but here are 2 issues I am facing
- it takes 15 secs for ‘screen 1’ to fade to ‘screen 2’ and so on but when i load a certain screen using the dropdown combobox,
the screens started to fade to the next screen really quickly, like within 2 seconds(it is supposed to be 15 secs) - i have certain buttons disabled when i am at the first and last screen. ‘previous’ button is disabled for first screen and
‘next’ button is disabled for the last screen. so now, when i use the dropdown to select a screen, certain buttons are wrongly disabled.
example: 1st screen has its ‘next’ button disabled so users are not able to move forward.
Can someone please help look through my codes and see what is wrong?
thanks!
stop();
var total;
var p = 0;
//variables for slideshow
var slide = 1;
var delay_slide;
//this is the interval between the pics: 15 seconds
var interS = 15000;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
image2 = [];
image3 = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
image2* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
image3* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
contents.addItem(description*, i);
}
loadPic(p);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
///////////////////////
function loadXML2(loaded) {
if (loaded) {
xmlNode2 = this.firstChild;
updated = [];
total2 = xmlNode2.childNodes.length;
for (i=0; i<total2; i++) {
updated* = xmlNode2.childNodes*.childNodes[0].firstChild.nodeValue;
}
updated_txt.text = updated[p];
} else {
content = "file not loaded!";
}
}
xmlData2 = new XML();
xmlData2.ignoreWhite = true;
xmlData2.onLoad = loadXML2;
xmlData2.load("updated.xml");
////////////////////////
function loadPic(p) {
picture.loadMovie(image[p]);
picture._alpha = 0;
picture2.loadMovie(image2[p]);
picture2._alpha = 0;
picture3.loadMovie(image3[p]);
picture3._alpha = 0;
var temp = this.createEmptyMovieClip("tem", 9978);
temp.onEnterFrame = function() {
var filesize = picture.getBytesTotal();
var loaded = picture.getBytesLoaded();
var filesize2 = picture2.getBytesTotal();
var loaded2 = picture2.getBytesLoaded();
var filesize3 = picture3.getBytesTotal();
var loaded3 = picture3.getBytesLoaded();
preloader._visible = true;
preloader.preload_bar._xscale = Math.round((loaded/filesize)*100);
preloader2._visible = true;
preloader2.preload_bar._xscale = Math.round((loaded2/filesize2)*100);
preloader3._visible = true;
preloader3.preload_bar._xscale = Math.round((loaded3/filesize3)*100);
if (picture._width && picture2._width && picture3._width) {
preloader._visible = false;
picture.fadeTo(100, 1.1);
preloader2._visible = false;
picture2.fadeTo(100, 1.1);
preloader3._visible = false;
picture3.fadeTo(100, 1.1);
picture_num();
picture._alpha += 7;
picture2._alpha += 7;
picture3._alpha += 7;
desc_txt.text = description[p];
if (picture._alpha>100 && picture2._alpha>100 && picture3._alpha>100) {
picture._alpha = 100;
picture2._alpha = 100;
picture3._alpha = 100;
//if the slideshow is running
if (slide) {
delay_slide = setInterval(showSlide, interS, total);
}
delete this.onEnterFrame;
}
}
};
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
previous_btn.onRelease();
} else if (Key.getCode() == Key.RIGHT) {
next_btn.onRelease();
}
};
Key.addListener(listen);
//combobox code
var listListener:Object = new Object();
listListener.change = function(evt_obj:Object) {
// Display each property of the object.
var currentlySelected:Object = evt_obj.target.selectedItem;
trace("data: "+currentlySelected.data);
trace("label: "+currentlySelected.label);
p=currentlySelected.data;
loadPic(p);
};
// Add listener.
contents.addEventListener("change", listListener);
//--
previous_btn.onRelease = function() {
//p>0 ? (p--, loadPic(p), pause_btn.onRelease()) : null;
if (p>0) {
p--;
loadPic(p);
pause_btn.onRelease();
previous_btn._alpha = 100;
previous_btn.enabled = 1;
next_btn._alpha = 100;
next_btn.enabled = 1;
} else {
next_btn._alpha = 100;
next_btn.enabled = 1;
null;
}
if (p == 0) {
previous_btn._alpha = 20;
previous_btn.enabled = 0;
next_btn._alpha = 100;
next_btn.enabled = 1;
}
};
next_btn.onRelease = function() {
//p<total-1 ? (p++, loadPic(p), pause_btn.onRelease()) : null;
//when it is still smaller than last node, array will still increase, previous btn
if (p<total-1) {
p++;
loadPic(p);
pause_btn.onRelease();
previous_btn._alpha = 100;
previous_btn.enabled = 1;
} else {
//previous_btn._alpha = 10;
//previous_btn.enabled = 0;
next_btn._alpha = 100;
next_btn.enabled = 1;
null;
}
if (p == total-1) {
next_btn._alpha = 20;
next_btn.enabled = 0;
previous_btn._alpha = 100;
previous_btn.enabled = 1;
}
};
/////////////////////////////////////
//function for the slideshow
function showSlide(total) {
//clear the interval (if there's a slideshow)
clearInterval(delay_slide);
//p<total-1 ? (p++, loadPic(p), setButtons(p)) : (p=0, loadPic(p), setButtons(p));
if (p<total-1) {
p++;
loadPic(p);
setButtons(p);
} else {
p = 0;
previous_btn._alpha = 20;
previous_btn.enabled = 0;
next_btn._alpha = 100;
next_btn.enabled = 1;
loadPic(p);
setButtons(p);
}
if (p>0) {
previous_btn._alpha = 100;
previous_btn.enabled = 1;
}
if (p == total-1) {
next_btn._alpha = 20;
next_btn.enabled = 0;
}
}
//default previous button disabled
previous_btn._alpha = 20;
previous_btn.enabled = 0;
//play button function
play_btn._alpha = 20;
play_btn.enabled = 0;
play_btn.onRelease = function() {
this._alpha = 20;
this.enabled = 0;
pause_btn._alpha = 100;
pause_btn.enabled = 1;
slide = 1;
showSlide(total);
};
//pause button function
pause_btn.onRelease = function() {
clearInterval(delay_slide);
slide = 0;
this._alpha = 20;
this.enabled = 0;
play_btn._alpha = 100;
play_btn.enabled = 1;
};