Original Post
I was fooling around with the DHTML tutorial on w3schools.com and I found the whole mouse over/changing opacity thing to be very interesting. It reminded me of the sexy play button on the new Windows Media Player cuz of the pulsing look. The tutorial only taught you how to implement the mouseover pulse and simply reset the opacity on mouseout, so I decided to try and implement my own mouseout version, but ran into trouble in two places: 1> If you mouseover then mouseout too fast, the transitions get stuck mid-shift. 2> Using the function for multiple images causes chaos. Basically, I am stuck on how to rearrange/rewrite the code so that it does not mess up so badly. If there are any HTML/javascript gurus out there willing to help me create awesomeness, I would very much appreciate it! Two notes: 1> Sorry for the inconvenience, this DHTML fading stuff only works with IE. 2> I hope it is okay that I linked to a picture on GameDev. ..For some odd reason, my plus signs don't show up in the preview window. Well, at any rate, there are plus signs before and after the "id" in the functions.
<html>
<head>
<style>
img
{
filter:alpha(opacity=10)
}
</style>
<script type="text/javascript">
function clean(id)
{
interval=setInterval("makeclean('" + id + "')",6)
}
function foggy(id)
{
interval=setInterval("makefoggy('" + id + "')",6)
}
function makefoggy(id)
{
if(document.getElementById(id).filters.alpha.opacity<=10)
{
clearInterval(interval)
}
else
{
document.getElementById(id).filters.alpha.opacity-=10
}
}
function makeclean(id)
{
if(document.getElementById(id).filters.alpha.opacity>=100)
{
clearInterval(interval)
}
else
{
document.getElementById(id).filters.alpha.opacity+=10
}
}
</script>
</head>
<body>
Mouse over the image-link:
<img border="0" id="myImage1" src="http://www.gamedev.net/community/forums/mod/news/icons/news16.png" onmouseover="clean('myImage1')"
onmouseout="foggy('myImage1')" />
<img border="0" id="myImage2" src="http://www.gamedev.net/community/forums/mod/news/icons/news16.png" onmouseover="clean('myImage2')"
onmouseout="foggy('myImage2')" />
<img border="0" id="myImage3" src="http://www.gamedev.net/community/forums/mod/news/icons/news16.png" onmouseover="clean('myImage3')"
onmouseout="foggy('myImage3')" />
<img border="0" id="myImage4" src="http://www.gamedev.net/community/forums/mod/news/icons/news16.png" onmouseover="clean('myImage4')"
onmouseout="foggy('myImage4')" />
</body>
</html>