/    Sign up×
Community /Pin to ProfileBookmark

stoping and resuming a slideshow

i have this rotating slide show, but i want to use a play and a pause button to stop it and get it going again. does anyone know how i can do that?

[CODE]// ———————————————–
// —> SmoothShow Javascript Slideshow <—
// —> Author: Znupi <—
// —> Contact: [email protected] <—
// ———————————————–

var ss1 = new SmoothShow(imgs, urls, ‘slideDIV1’, 1, 2, 50, 0.05);

function SmoothShow(aImg, aUrl, sID, bWait, iPause, iDelay, iStep) {
var imgs = aImg;
var urls = aUrl;
var preLoadObjs = Array();
var loadedImgs = 0;
var totalImgs= 0;
var wait = bWait;
var pause = iPause;
var delay = iDelay;
var step = iStep;
var curIndex = 0;
var curImgSet = 0;
var curOpc = 0;
var curDir = 1;
var tOut = null;
var sID = sID;
var oDIV = null;
var oIMG = null;
var i;
this.init = function() {
oDIV = document.getElementById(sID);
oIMG = oDIV.getElementsByTagName(“img”)[0];
for (i=0; i < imgs.length; i++) totalImgs += imgs[i].length;
for (i=0; i < imgs.length; i++) {
for (j=0; j < imgs[i].length; j++) {
preLoadObjs[preLoadObjs.length] = new Image();
preLoadObjs[preLoadObjs.length-1].src = imgs[i][j];
if (!window.opera) preLoadObjs[preLoadObjs.length-1].onload = countLoadedImgs;
if ( ( i == imgs.length-1 && j == imgs[i].length-1 ) && ( window.opera || wait ) ) {
start();
}
}
}
}
var countLoadedImgs = function() {
loadedImgs++;
if (loadedImgs == totalImgs && !wait) start();
}
var start = function(n) {
oIMG.src = imgs[curImgSet][0];
if (n) {
oIMG.style.opacity = “1”;
if (window.ActiveXObject) oIMG.style.filter = “alpha (opacity=100)”;
curOpc = 1;
oDIV.style.backgroundImage = “url(‘” + imgs[curImgSet][1] + “‘)”;
}
curIndex++;
if (n) tOut = setTimeout(doSlide, pause*1000);
else doSlide();
}
var doSlide = function() {
if (!curDir) {
curOpc-=step;
if (curOpc < 0) curOpc = 0;
oIMG.style.opacity = curOpc;
if (window.ActiveXObject) oIMG.style.filter = “alpha (opacity=” + (curOpc*100) + “)”;
if (curOpc > 0) tOut = setTimeout(doSlide, delay);
else {
changeImgs();
curDir = 1;
tOut = setTimeout(doSlide, pause*1000);
}
}
else {
curOpc+=step;
if (curOpc > 1) curOpc = 1;
oIMG.style.opacity = curOpc;
if (window.ActiveXObject) oIMG.style.filter = “alpha (opacity=” + (curOpc*100) + “)”;
if (curOpc < 1) tOut = setTimeout(doSlide, delay);
else {
changeImgs();
curDir = 0;
tOut = setTimeout(doSlide, pause*1000);
}
}
}
var changeImgs = function() {
if (curIndex < imgs[curImgSet].length-1) curIndex++;
else curIndex = 0;
if (!curDir) {
oIMG.src = imgs[curImgSet][curIndex];
curOpc = 0;
oIMG.style.opacity = 0;
}
else oDIV.style.backgroundImage = “url(‘” + imgs[curImgSet][curIndex] + “‘)”;
}
this.chgImgSet = function(newImgSet) {
if (newImgSet != curImgSet) {
clearTimeout(tOut);
curImgSet = newImgSet;
curIndex = 0;
start(1);
}
}
}
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@TinaBananaauthorJun 13.2008 — anyone pls?
×

Success!

Help @TinaBanana spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...