I’m making a slideshow. It uses senoculars preloadnextimage.fla-source, and a simple timer to play through the images. I’m not a good actionscripter, so I will be very glad if anyone could help me make the image underneath (the one that doesn’t show) invisible. Also I need to find a solution for setting the size of my images.
Thanks in advance
ps: here’s my code:
// baseurl to use to locate images based on SWF url not HTML url
var baseurl = _url.substr(0,_url.lastIndexOf("/")+1);
// create and position empty clips for images
// one for visible image, one which will be
// used for preloading the next image
this.createEmptyMovieClip("one",2); // on top
this.createEmptyMovieClip("two",1);
one._x = two._x = 0;
one._y = two._y = 0;
// clips represents the clips with images
clips = [
one,
two
];
timeline = this; // allows reference to timeline from other clips
// images is an array of the names of the images being used
// this is for file referencing as well as status display
images = [
"toforti01",
"chair01",
"chair02"
];
// GetFileFor returns the file path for an image
// given its name
function GetFileFor(name){
return baseurl+"img/"+name+".jpg";
}
// Preload checks to see if a clip has been loaded
function Preload(clip){
var lod = clip.getBytesLoaded();
var tot = clip.getBytesTotal();
if (lod && tot){
var percent_loaded = lod/tot;
progress_mc._xscale = 100* percent_loaded;
if (lod == tot){
status_txt.text = "Preloading complete for "+images[0];
return true; // is complete
}
}
return false; // is not complete
}
// PreloadNext is used as an onEnterFrame event
// to check the loading of the current image and
// reorders the arrays so that the first element
// now represents the next image/clip
function PreloadNext(){
var is_complete = Preload(clips[0]);
if (is_complete){
clips.push(clips.shift()); // shift order of arrays
images.push(images.shift());
delete this.onEnterFrame;
}
}
// FirstLoad is like PreloadNext but loads the first image
// adding in a status message otherwise handled by the next button
// and starting the second image to load when complete.
function FirstLoad(){
var is_complete = Preload(clips[0]);
if (is_complete){
clips.push(clips.shift());
images.push(images.shift());
clips[0].loadMovie(GetFileFor(images[0]));
status_txt.text = "Preloading "+images[0];
this.onEnterFrame = PreloadNext;
}
}
import mx.transitions.Tween;
import mx.transitions.easing.*;
var playTimer:Tween = new Tween(timer.timerBar, "_width", Regluar, 0, 200, 3, true);
playTimer.onMotionFinished = function() {
var resetTimer:Tween = new Tween(timer.timerBar, "_width", Strong.easeOut, 200, 0, 0.3, true);
resetTimer.onMotionFinished = function() {
playTimer.start();
};
// the timer shows the next image if preloaded and starts
// preloading the next one using PreloadNext as an onEnterFrame event
if (_parent.onEnterFrame){
status_txt.text = "Please wait for "+images[0]+" to complete";
return false;
}
clips[0].swapDepths(clips[1]); // move preloaded image to top
clips[0].loadMovie(GetFileFor(images[0]));
status_txt.text = "Preloading "+images[0];
timeline.onEnterFrame = PreloadNext;
};
// initiate loading of first image
clips[0].loadMovie(GetFileFor(images[0]));
status_txt.text = "Preloading "+images[0];
this.onEnterFrame = FirstLoad;