scriptkeeper
07-23-2003, 08:04 AM
Hello all I have an image fading function for a slideshow. And I would like it to fade out the image change to next image then fade in the new image and I have tried everything I can think of any ideas!
<!--
pixs=["0001.jpg","0002.jpg","0003.jpg","0004.jpg","0005.jpg","0006.jpg","0007.jpg","0008.jpg","0009.jpg","0010.jpg",];
pix=[]
for(i=0;i<pixs.length;i++){
pix[i]=new Image();
pix[i].src=pixs[i];}
isImage=0;
imCt=pix.length-1;
document.onkeyup=keyStruck;
go_timer="";
fade_timer="";
shuffleSpeed=5000;
p=100;
if(document.layers){
document.captureEvents(Event.KEYDOWN);
leftArrow=28;
rightArrow=29;
}else{
leftArrow=37;
rightArrow=39;
}
function keyStruck(evt){
if(evt){
key_struck=evt.which;
}else{
key_struck=window.event.keyCode;
}
if(key_struck==leftArrow)nextImage(-1);
else if(key_struck==rightArrow)nextImage(1);
}
function stop(){clearTimeout(go_timer);}
function selected(){
isImage=document.selectIt.pictureList.selectedIndex;
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
function go(){
clearTimeout(go_timer)
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
go_timer=setTimeout("go()",shuffleSpeed);
isImage=isImage+1;
if(isImage==10)isImage=0;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
function nextImage(direction){
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
if(document.images){
isImage=isImage+direction;
if(isImage>imCt)isImage=0;
if(isImage<0)isImage=imCt;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
}
function imageFader(){
fade_timer=setTimeout("imageFader()",0);
if(p>0)p=p-1;
document.mainShow.filters.alpha.opacity=p;
if(p<=0){
document.images.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
if(p<100)p=p+1;
document.mainShow.filters.alpha.opacity=p;
clearTimeout(fade_timer);
}
}
-->
<!--
pixs=["0001.jpg","0002.jpg","0003.jpg","0004.jpg","0005.jpg","0006.jpg","0007.jpg","0008.jpg","0009.jpg","0010.jpg",];
pix=[]
for(i=0;i<pixs.length;i++){
pix[i]=new Image();
pix[i].src=pixs[i];}
isImage=0;
imCt=pix.length-1;
document.onkeyup=keyStruck;
go_timer="";
fade_timer="";
shuffleSpeed=5000;
p=100;
if(document.layers){
document.captureEvents(Event.KEYDOWN);
leftArrow=28;
rightArrow=29;
}else{
leftArrow=37;
rightArrow=39;
}
function keyStruck(evt){
if(evt){
key_struck=evt.which;
}else{
key_struck=window.event.keyCode;
}
if(key_struck==leftArrow)nextImage(-1);
else if(key_struck==rightArrow)nextImage(1);
}
function stop(){clearTimeout(go_timer);}
function selected(){
isImage=document.selectIt.pictureList.selectedIndex;
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
function go(){
clearTimeout(go_timer)
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
go_timer=setTimeout("go()",shuffleSpeed);
isImage=isImage+1;
if(isImage==10)isImage=0;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
function nextImage(direction){
fadeHandle=document.selectIt.op.checked;
randomHandle=document.selectIt.ran.checked;
if(document.images){
isImage=isImage+direction;
if(isImage>imCt)isImage=0;
if(isImage<0)isImage=imCt;
if(randomHandle){
isImage=Math.floor(Math.random()*imCt);
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
if(fadeHandle)imageFader();
else{
document.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
}
}
}
function imageFader(){
fade_timer=setTimeout("imageFader()",0);
if(p>0)p=p-1;
document.mainShow.filters.alpha.opacity=p;
if(p<=0){
document.images.mainShow.src=pix[isImage].src;
document.selectIt.pictureList.selectedIndex=isImage;
if(p<100)p=p+1;
document.mainShow.filters.alpha.opacity=p;
clearTimeout(fade_timer);
}
}
-->