Here is the code. Seems to me very similar to most Slideshow/Galleries that I’ve seen. It has all the functions you would need like next button, fade in, auto or manual… hence the lengthy code. But all I need really is to change some Var to a Random number, so my images load randomly… shouldn’t be too hard. I usually do it without too much trouble.
All i should have to do is to place [COLOR=“DarkOrange”]Math.floor(Math.random()*(nodeCount.length));[/COLOR] somewhere… but where?
[AS]
/////////////////////Settings
startState = “auto”;
// use “manual” for manual start
// use “auto” for auto start
var numFadeRate = 5;
// Fade in and out rate. You can change it if you want a faster or slower fade in and out.
// Slide Function (Fade out and unload pictures from the image_mc movie clip)
var xmlSource = “images.xml”;
//////////////////////// Handler Script
switch (startState) {
case “auto” :
// setTimerCtrl();
// Check the seleced timer control
_root.man_mc._visible = false;
// Hide manual controls
_root.timer_mc._visible = true;
auto.selected = true;
// setTimerCtrlAuto();
break;
case “manual” :
clearInterval(intervalID);
_root.man_mc._visible = true;
// Show manual controls
_root.timer_mc._visible = false;
// Hide auto controls
manual.selected = true;
break;
default :
trace(“no case tested true”);
}
stop();
listenerObject = new Object();
listenerObject.click = function(eventObject) {
selectState();
};
radioButtonGroup.addEventListener(“click”, listenerObject);
//////////////////////// Auto / Manual switch
// _root.man_mc._visible = false;
// Show manual controls
function setTimerCtrlAuto() {
// if (_root.image_mc.getBytesLoaded() == _root.image_mc.getBytesTotal()) {
// intervalID = setInterval(autoSlideNew, 6000);
// Set an interval for auto slide
// }
}
function autoSlideNew() {
if (_root.image_mc.getBytesLoaded() == _root.image_mc.getBytesTotal()) {
if (currentRecord == nodeCount) {
loadNumber = 1;
} else {
loadNumber = currentRecord+1;
}
imgSlide();
}
trace(_global.myTrigger);
}
function setTimerCtrl() {
if (_root.image_mc.getBytesLoaded() == _root.image_mc.getBytesTotal()) {
autoTimer = Number(((_root.timer_mc.setTimer.getSelectedItem().label)*1000)+2000);
// Check the selected timer
clearInterval(intervalID);
// Clear the interval for auto slide
intervalID = setInterval(autoSlide, autoTimer);
// Set an interval for auto slide
}
}
function selectState() {
if (auto.selected == true) {
// Check if the auto radio button is selected
// setTimerCtrl();
// Check the seleced timer control
_root.man_mc._visible = false;
// Hide manual controls
_root.timer_mc._visible = true;
// trace(_root.timer_mc.setTimer.getSelectedItem().label);
// Show auto controls
// Hide the arrows
// if (_root.image_mc.getBytesLoaded() == _root.image_mc.getBytesTotal()) {
autoTimer = Number(((_root.timer_mc.setTimer.getSelectedItem().label)*1000)+2000);
// Check the selected timer
clearInterval(intervalID);
// Clear the interval for auto slide
intervalID = setInterval(autoSlide, autoTimer);
// Set an interval for auto slide
// }
} else if (manual.selected == true) {
clearInterval(intervalID);
// Check if the manual radio button is selected
_root.man_mc._visible = true;
// Show manual controls
_root.timer_mc._visible = false;
// Hide auto controls
// Clear the interval created from the auto state.
}
}
//////////////////////// SLIDE FUNCTIONS
image_mc._alpha = 0;
// Hide the image movie clip
// Declare variables
function imgSlide() {
onEnterFrame = function () {
image_mc._alpha -= numFadeRate;if (image_mc._alpha<0) {delete onEnterFrame;image_mc.unloadMovie();
showRecord(loadNumber);}
};
}
// Fade in function
function show() {
onEnterFrame = function () { if (_global.myTrigger == “laoded”) {image_mc._alpha += numFadeRate;if (image_mc._alpha>100) {delete onEnterFrame;}} else if (_global.myTrigger == “laoding”) {image_mc._alpha = 0;}};
}
// Load slide function. Dynamicly load pictures from “img” folder.
function autoSlide() {
if (currentRecord == nodeCount) {
loadNumber = 1;
} else {
loadNumber = currentRecord+1;
}
imgSlide();
}
// Jump to image function
function goToImage() {
if (loadNumber != _root.man_mc.dynGo.getSelectedItem().label) {
loadNumber = _root.man_mc.dynGo.getSelectedItem().label;
imgSlide();
}
}
/////////////////////////// XML FUNCTIONS
currentRecord = 0;
// Variable used to keep track of the current image
// function for onLoad method of xmlObject
function dataLoaded(complete) {
if (complete) {
_root.man_mc.dynGo.removeAll();
nodeCount = this.firstChild.childNodes.length;
// Check the image count from the xml file
showRecord(1);
_root.man_mc.dynGo.rowCount = nodeCount;
// set the rowcount of jump menu
for (i=1; i<=nodeCount; i++) {
// Add numbers to jump menu
_root.man_mc.dynGo.addItem(i);
}
_root.man_mc.dynGo.rowCount = 20;
}
}
// XML declaration and loading
xmlObject = new XML();
xmlObject.ignoreWhite = true;
xmlObject.onLoad = dataLoaded;
xmlObject.load(xmlSource);
//////////////////////////////////////////////// NEXT PREVIOUS BUTTONS FUNCTIONS
// function to be run by “next” button
function showNext() {
if (currentRecord == nodeCount) {
loadNumber = 1;
} else {
loadNumber = currentRecord+1;
}
imgSlide();
}
// function to be run by “previous” button
function showPrevious() {
if (currentRecord == 1) {
loadNumber = nodeCount;
} else {
loadNumber = currentRecord-1;
}
imgSlide();
}
// function to set variable names/display fields
function showRecord(recordNumber) {
var nodeObject = xmlObject.firstChild.childNodes[recordNumber-1];
titled = nodeObject.childNodes[0].childNodes[0].nodeValue;
// description.html = true;
description = nodeObject.childNodes[1].childNodes[0].nodeValue;
media = nodeObject.childNodes[2].childNodes[0].nodeValue;
// trace(media);
_global.myTrigger = “”;
slideFilename = “img/”+media+"";
image_mc.loadMovie(slideFilename);
onEnterFrame = function () { bytesLoaded = _root.image_mc.getBytesLoaded();trace(_global.myTrigger);if (_global.myTrigger == “laoded”) {selectState();delete onEnterFrame;show();} else if (_global.myTrigger == “laoding”) {image_mc._alpha = 0;clearInterval(intervalID);}};
currentRecord = recordNumber;
_root.man_mc.dynGo.setSelectedIndex(currentRecord-1);
}
[/AS]