Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Dissolve Between Pix in Slide Show?

Status
Not open for further replies.

flasher40

Technical User
Apr 13, 2007
80
US
Hello,

I've use the code below, supplied by Trollacious, and it has worked well for me, but I was wondering if there's a way to adapt it to have dissolves between slides. Or a different approach that would accomplish that goal.

Thanks!
Bill

___________________________________________________________

<form><input type="button" value="<- Back" onclick="clearInterval(slideshow); clickphoto(-1);">&nbsp;<input type="button" value="Resume Slideshow" onclick="slideshow=setInterval('swapimage()', 10000);">&nbsp;<input type="button" value="Next ->" onclick="clearInterval(slideshow); clickphoto(1);"></form>
<div id="caption" style="font-family:arial; font-size:13;"></div><br>
<img name="photo">

<script language="javascript">

function clickphoto(direction)
{
pi += direction;
pi %= photo.length;
if (pi ==-1) pi = photo.length - 1;
displayphoto(pi);

}

function swapimage()
{
pi++;
pi %= photo.length;
displayphoto(pi);
}

function displayphoto(photonum)
{
document.images['photo'].src=photo[photonum].name;
caption.innerHTML=(photonum + 1) + ' of ' + photo.length + '<br>&nbsp;';
if (photo[photonum].caption.length > 0)
{
caption.innerHTML+='<b>' + photo[photonum].caption + '</b>';
}
caption.innerHTML+='&nbsp;';
}

function Photo(name, caption)
{
this.name=name;
this.caption=caption;
return this;
}

var photo=new Array(), pi=0;

photo[pi++]=new Photo('photoname1','Caption1');
photo[pi++]=new Photo('photoname2','Caption2');
photo[pi++]=new Photo('photoname3','Caption3');

pi=0;

var caption=document.getElementById('caption');
displayphoto(pi);

var images=new Array();

for (var ii=0;ii<photo.length;ii++)
{
images[ii]=new Image();
images[ii].src=photo[ii].name;
}

var slideshow=setInterval('swapimage()', 10000);

</script>
 
You would need to modify the code at around displayphoto(). I would use an opacity fade (where you decrease the opacity of the old image whilst increasing the opacity of the new image) across both images (which need to be overlayed one atop the other).

There are some annoying issues to do with setting opacity across the IE browsers.

Let us know how you go!
Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Jeff,

Since I'm not a programmer, I'd need someone to provide the code. But it sounds like there may be issues that outweigh the advantages. I don't want the solution to cause problems for some users.

Bill
 
Since I'm not a programmer, I'd need someone to provide the code.

Sorry, but I think you've confused what the purpose of this site is. Many here will gladly help you write the script, but I think you're out of luck if you want someone to write it for you.

If you really just want someone to do it for you, try here:


-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Kaht,

With all due respect, is it written in stone that no programmer will provide me with code? I mean, is it some kind of hard-and-fast rule, or does each programmer have the freedom to decide what they will or will not provide? (I mean, the Internet is about freedom, isn't it?) The reason I ask is that your comment doesn't fit with my experience, because I can't count the number of times Javascript and Flash programmers have been kind enough to provide me with code (such as the code shown in my initial posting), for which I have been and continue to be immensely grateful. Usually, I suspect, it is code they already have on hand or can create off the top of their heads in a few minutes.

I'm continually at awe with what you and other programmers are able to do, and I've tried several times to learn your craft, but I just don't seem to be wired that way. So, I learn as much as I can, and rely on books, online tutorials, and forums like this for help when I need it. I hope some programmers will continue to be as generous with their time and talent as they have in the past.

Respectfully,
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top