Cipes
10-21-2008, 08:39 PM
hi There, It will become quite obvious that Im very inexperienced, and Im trying to amalgamate a few tutorials together in order to get what I need.
Its a XML based slide show that's randomly generated. I've been trying to tweak it in order that the first picture loaded is randomly generated and then from there onwards it progresses from one picture to the next in order.
Here's the codeimport mx.transitions.Tween;
import mx.transitions.easing.*;
pauseTime = 4000;
xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");
function loadImages(loaded)
{ if (loaded) { xmlFirstChild = this.firstChild; imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) { imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;}
randomImage();
}
}
function randomImage()
{ if (loaded == filesize)
{var ran = Math.round(Math.random() * (totalImages - 1));
picture_mc._alpha = 0; // Start image clip as invisible
picture_mc.loadMovie(imageFileName[ran], 1); //Load random image from xml
var pictureTweenIn:Tween = new Tween (picture_mc,"_alpha",Normal.easeIn,0,100,1,true); //
pictureTweenIn.onMotionFinished = function () { // When done fading
_root.pause(); // Start pause() function
}
}
}
function pause() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
var pictureTweenOut:Tween = new Tween (picture_mc,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
pictureTweenOut.onMotionFinished = function () { // Once faded out
_root.slideShow(); // Call next Image in order after random()
}
}
}
function slideShow() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
nextImage();
}
}
function nextImage() {
//if (i<(totalImages-1)) {
//i++;
if (loaded == filesize) {
{
picture_mc._alpha = 0; // Start image clip as invisible
picture_mc.loadMovie(imageFileName[ran],1); //Load next image from xml
var pictureTweenIn:Tween = new Tween (picture_mc,"_alpha",Normal.easeIn,0,100,1,true); //
pictureTweenIn.onMotionFinished = function () { // When done fading
_root.pause(); // Start pause() function
slideShow();
}
}
}
}
Basically I want to secure the var ran declared in the randomImage
function and just continue in the nextImage fuction by adding +1 to it and and repeating the slideShow function.
Is the ran value accessible outside of its block? seems to be a local variable.
I know nothing really. Thanks for any help you can give.
Its a XML based slide show that's randomly generated. I've been trying to tweak it in order that the first picture loaded is randomly generated and then from there onwards it progresses from one picture to the next in order.
Here's the codeimport mx.transitions.Tween;
import mx.transitions.easing.*;
pauseTime = 4000;
xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load("images.xml");
function loadImages(loaded)
{ if (loaded) { xmlFirstChild = this.firstChild; imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) { imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;}
randomImage();
}
}
function randomImage()
{ if (loaded == filesize)
{var ran = Math.round(Math.random() * (totalImages - 1));
picture_mc._alpha = 0; // Start image clip as invisible
picture_mc.loadMovie(imageFileName[ran], 1); //Load random image from xml
var pictureTweenIn:Tween = new Tween (picture_mc,"_alpha",Normal.easeIn,0,100,1,true); //
pictureTweenIn.onMotionFinished = function () { // When done fading
_root.pause(); // Start pause() function
}
}
}
function pause() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
var pictureTweenOut:Tween = new Tween (picture_mc,"_alpha",Normal.easeOut,100,0,1,true); // After pause, start fade out
pictureTweenOut.onMotionFinished = function () { // Once faded out
_root.slideShow(); // Call next Image in order after random()
}
}
}
function slideShow() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
nextImage();
}
}
function nextImage() {
//if (i<(totalImages-1)) {
//i++;
if (loaded == filesize) {
{
picture_mc._alpha = 0; // Start image clip as invisible
picture_mc.loadMovie(imageFileName[ran],1); //Load next image from xml
var pictureTweenIn:Tween = new Tween (picture_mc,"_alpha",Normal.easeIn,0,100,1,true); //
pictureTweenIn.onMotionFinished = function () { // When done fading
_root.pause(); // Start pause() function
slideShow();
}
}
}
}
Basically I want to secure the var ran declared in the randomImage
function and just continue in the nextImage fuction by adding +1 to it and and repeating the slideShow function.
Is the ran value accessible outside of its block? seems to be a local variable.
I know nothing really. Thanks for any help you can give.