chris_angell
07-16-2002, 01:31 PM
question, when the image changes to one of the 3 rotating images. why do they not individually fade in each time ???
this was my plan. is it easy to adapt the code to do this.. ;)
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<link rel="stylesheet" class="menu" href="css/divs.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var rand1 = 0;
var useRand = 0;
images = new Array;
images[1] = new Image();
images[1].src = "images/robot_1.jpg";
images[2] = new Image();
images[2].src = "images/robot_2.jpg";
images[3] = new Image();
images[3].src = "images/robot_3.jpg";
function swapPic() {
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg.src = images[useRand].src;
}
function doFadeInImg(imgToFade) {
imgToFade.filters.alpha.opacity=imgToFade.filters.alpha.opacity+6
setTimeout('doFadeInImg(document.images.' + imgToFade.id + ')',15)
}
// -->
</script>
</head>
<body onLoad="setTimeout('doFadeInImg(document.images.robot)',500);">
<div id="robotDiv">
<img name="randimg" id="robot" src="images/robot_1.jpg" width="320" height="535" style="filter:alpha(opacity=0)"></div>
<a href="#" onClick="swapPic();setTimeout('doFadeInImg(document.images.robot)',500);"><span style="background-color: #808000">change</span></a><span style="background-color: #808000">
</span>
</body>
</html>
thanks <marquee>:eek: </marquee>
this was my plan. is it easy to adapt the code to do this.. ;)
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<link rel="stylesheet" class="menu" href="css/divs.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var rand1 = 0;
var useRand = 0;
images = new Array;
images[1] = new Image();
images[1].src = "images/robot_1.jpg";
images[2] = new Image();
images[2].src = "images/robot_2.jpg";
images[3] = new Image();
images[3].src = "images/robot_3.jpg";
function swapPic() {
var imgnum = images.length - 1;
do {
var randnum = Math.random();
rand1 = Math.round((imgnum - 1) * randnum) + 1;
} while (rand1 == useRand);
useRand = rand1;
document.randimg.src = images[useRand].src;
}
function doFadeInImg(imgToFade) {
imgToFade.filters.alpha.opacity=imgToFade.filters.alpha.opacity+6
setTimeout('doFadeInImg(document.images.' + imgToFade.id + ')',15)
}
// -->
</script>
</head>
<body onLoad="setTimeout('doFadeInImg(document.images.robot)',500);">
<div id="robotDiv">
<img name="randimg" id="robot" src="images/robot_1.jpg" width="320" height="535" style="filter:alpha(opacity=0)"></div>
<a href="#" onClick="swapPic();setTimeout('doFadeInImg(document.images.robot)',500);"><span style="background-color: #808000">change</span></a><span style="background-color: #808000">
</span>
</body>
</html>
thanks <marquee>:eek: </marquee>