adrowl
10-21-2003, 06:05 PM
I am trying to use this code from actionscript.toolbox. It works great if your photos are all the same size. My pictures vary greatly and the swap depths doesn't work or the fade in and out. I'll make the pictures smaller but can a continous slide show with about 80 photos be shown without having the user press a button for each photo?
TIA,
Annette#initclip 1
/**
* @class Slideshow
* @author Helen Triolo
* @date 31/07/2003
* @version 1.01 : chg'd activateNext to activateInSeq,
* commented all,
* make onSlideLoaded broadcast work for all, including last
*
* Slideshow constructor, also make it a broadcaster and starts loading
* Properties:
* slides_arr Array holding urls of jpg/swfs to be loaded
* slideDepth Integer specifying depth to start loading slides to (incremented on each slide display)
* fps Integer specifying movie framerate so setInterval can emulate
* nFrames Integer specifying frames to hold slide visible
* alphaIncr Number specifying alpha change per frame
* repeat Boolean indicating whether slideshow should loop
*/
Slideshow = function() {
// trace('slideshow created');
ASBroadcaster.initialize(this);
this.loadInSeq(0);
}
Slideshow.prototype = new MovieClip ();
/**
* @method loadInSeq
* @param i Integer Slide number to be loaded next
*
* Creates movieclip slide<i> in Slideshow, sets vis & alpha,
* starts loading content.. repeats for next i slide til all loaded
*/
Slideshow.prototype.loadInSeq = function(i) {
var slide = this.createEmptyMovieClip("slide" + i, this.slideDepth++);
// hide all slides loading on top of first one
if (i > 0) slide._alpha = 0;
slide.loadMovie(this.slides_arr[i]);
checkLoadedID = setInterval(function(i, mc) {
if (mc["slide" + i]._width > 0) {
mc["slide" + i]._visible = true;
mc.broadcastMessage("onSlideLoaded", i);
clearInterval(checkLoadedID);
// start next one loading (if not last)
if (i < mc.slides_arr.length-1) {
mc.loadInSeq(i + 1);
} else {
mc.broadcastMessage("onAllSlidesLoaded");
}
}
}, 1000/this.fps, i, this);
};
/**
* @method beginTransitions
* @param i Integer, Slide number to be affected
*
* Hold present slide for nFrames, then start rest transitioning
*/
Slideshow.prototype.beginTransitions = function() {
var holdTimeMs = 1000 * this.nFrames / this.fps;
holdID = setInterval(function(mc) { mc.activateInSeq(0); clearInterval(holdID); }, holdTimeMs, this);
};
/**
* @method activateInSeq
* @param i Integer Current slide number, 0 to start
*
* Put next slide (w/alpha=0) above current one (depthwise), fades it
* in, loops to next i and repeats til all done (or forever starting again
* at slide 0 if repeat is true)
*/
Slideshow.prototype.activateInSeq = function(i) {
// trace('in activateInSeq, i='+i);
if (++i < this.slides_arr.length) {
this["slide" + i]._alpha = 0;
this.onEnterFrame = function() {
if (this["slide" + i]._alpha >= 95) {
var counter = this.nFrames;
this.onEnterFrame = function() {
if (!counter--) {
delete this.onEnterFrame;
this.activateInSeq(i);
}
};
} else {
this["slide" + i]._alpha += this.alphaIncr;
}
};
} else {
if (this.repeat) this.activateInSeq(-1);
else this.broadcastMessage("onShowOver");
}
};
Object.registerClass("slideshow", Slideshow);
#endinitclip
TIA,
Annette#initclip 1
/**
* @class Slideshow
* @author Helen Triolo
* @date 31/07/2003
* @version 1.01 : chg'd activateNext to activateInSeq,
* commented all,
* make onSlideLoaded broadcast work for all, including last
*
* Slideshow constructor, also make it a broadcaster and starts loading
* Properties:
* slides_arr Array holding urls of jpg/swfs to be loaded
* slideDepth Integer specifying depth to start loading slides to (incremented on each slide display)
* fps Integer specifying movie framerate so setInterval can emulate
* nFrames Integer specifying frames to hold slide visible
* alphaIncr Number specifying alpha change per frame
* repeat Boolean indicating whether slideshow should loop
*/
Slideshow = function() {
// trace('slideshow created');
ASBroadcaster.initialize(this);
this.loadInSeq(0);
}
Slideshow.prototype = new MovieClip ();
/**
* @method loadInSeq
* @param i Integer Slide number to be loaded next
*
* Creates movieclip slide<i> in Slideshow, sets vis & alpha,
* starts loading content.. repeats for next i slide til all loaded
*/
Slideshow.prototype.loadInSeq = function(i) {
var slide = this.createEmptyMovieClip("slide" + i, this.slideDepth++);
// hide all slides loading on top of first one
if (i > 0) slide._alpha = 0;
slide.loadMovie(this.slides_arr[i]);
checkLoadedID = setInterval(function(i, mc) {
if (mc["slide" + i]._width > 0) {
mc["slide" + i]._visible = true;
mc.broadcastMessage("onSlideLoaded", i);
clearInterval(checkLoadedID);
// start next one loading (if not last)
if (i < mc.slides_arr.length-1) {
mc.loadInSeq(i + 1);
} else {
mc.broadcastMessage("onAllSlidesLoaded");
}
}
}, 1000/this.fps, i, this);
};
/**
* @method beginTransitions
* @param i Integer, Slide number to be affected
*
* Hold present slide for nFrames, then start rest transitioning
*/
Slideshow.prototype.beginTransitions = function() {
var holdTimeMs = 1000 * this.nFrames / this.fps;
holdID = setInterval(function(mc) { mc.activateInSeq(0); clearInterval(holdID); }, holdTimeMs, this);
};
/**
* @method activateInSeq
* @param i Integer Current slide number, 0 to start
*
* Put next slide (w/alpha=0) above current one (depthwise), fades it
* in, loops to next i and repeats til all done (or forever starting again
* at slide 0 if repeat is true)
*/
Slideshow.prototype.activateInSeq = function(i) {
// trace('in activateInSeq, i='+i);
if (++i < this.slides_arr.length) {
this["slide" + i]._alpha = 0;
this.onEnterFrame = function() {
if (this["slide" + i]._alpha >= 95) {
var counter = this.nFrames;
this.onEnterFrame = function() {
if (!counter--) {
delete this.onEnterFrame;
this.activateInSeq(i);
}
};
} else {
this["slide" + i]._alpha += this.alphaIncr;
}
};
} else {
if (this.repeat) this.activateInSeq(-1);
else this.broadcastMessage("onShowOver");
}
};
Object.registerClass("slideshow", Slideshow);
#endinitclip