T
The Mysterious Mr. Rocco
Hi,
I'm trying to write a small piece of javascript, which will
alternately show two small red and yellow dots, with a time difference
of 500 ms between showing red and yellow. Then, I'd like the animation
to pause for 5 seconds, and then go back to the red/yellow sequence,
then pause for 5 seconds etc.
This is the code I've come up with:
// xml, DTD declarations to do later, etc.
<html>
<head>
<script type="text/javascript" language="JavaScript">
var pictures1 = new Array
// List all the pictures in the slideshow here
(
"red_dot.JPG"
,"yellow_dot.JPG"
);
var picture_num1 = 0;
var current_picture1 = new Image();
current_picture1.src = pictures1[picture_num1];
function start_show()
{
// Time is in milliseconds
setInterval("slideshow()", 500);
}
function slideshow()
{
picture_num1++;
if (picture_num1 == pictures1.length)
{
/// xxxxxxxxxxxxxxxxxxxx
picture_num1 = 0;
}
current_picture1.src = pictures1[picture_num1];
document["rotating_picture1"].src = current_picture1.src;
}
</script>
</head>
<body OnLoad="start_show()">
<style type="text/css">
..imgA1 { position:absolute; top: 25px; left: 25px; z-index: 1; }
..imgB1 { position:absolute; top: 25px; left: 25px; z-index: 3; }
</style>
<img class=imgA1 src="backdrop.JPG">
<img name="rotating_picture1" class=imgB1 src="red_dot.JPG">
</body>
</html>
I've managed to get the red/yellow flicking working, but can't get the
pause to work between
the red/yellow cycles.
I've tried putting in setTimeout("resetarray()", 5000); at the line
marked // xxxxxxxxxxx
with
function resetarray()
{
picture_num1 = 0;
}
but the javascript just hangs. I've tried putting in a simple timer,
comparing Date.getTime() with
(Date.getTime() + pause_interval) but this just hangs with a dialog
box saying that the "script has stopped responding" type message from
the browser..
Can anyone help?
Thanks
Trev
I'm trying to write a small piece of javascript, which will
alternately show two small red and yellow dots, with a time difference
of 500 ms between showing red and yellow. Then, I'd like the animation
to pause for 5 seconds, and then go back to the red/yellow sequence,
then pause for 5 seconds etc.
This is the code I've come up with:
// xml, DTD declarations to do later, etc.
<html>
<head>
<script type="text/javascript" language="JavaScript">
var pictures1 = new Array
// List all the pictures in the slideshow here
(
"red_dot.JPG"
,"yellow_dot.JPG"
);
var picture_num1 = 0;
var current_picture1 = new Image();
current_picture1.src = pictures1[picture_num1];
function start_show()
{
// Time is in milliseconds
setInterval("slideshow()", 500);
}
function slideshow()
{
picture_num1++;
if (picture_num1 == pictures1.length)
{
/// xxxxxxxxxxxxxxxxxxxx
picture_num1 = 0;
}
current_picture1.src = pictures1[picture_num1];
document["rotating_picture1"].src = current_picture1.src;
}
</script>
</head>
<body OnLoad="start_show()">
<style type="text/css">
..imgA1 { position:absolute; top: 25px; left: 25px; z-index: 1; }
..imgB1 { position:absolute; top: 25px; left: 25px; z-index: 3; }
</style>
<img class=imgA1 src="backdrop.JPG">
<img name="rotating_picture1" class=imgB1 src="red_dot.JPG">
</body>
</html>
I've managed to get the red/yellow flicking working, but can't get the
pause to work between
the red/yellow cycles.
I've tried putting in setTimeout("resetarray()", 5000); at the line
marked // xxxxxxxxxxx
with
function resetarray()
{
picture_num1 = 0;
}
but the javascript just hangs. I've tried putting in a simple timer,
comparing Date.getTime() with
(Date.getTime() + pause_interval) but this just hangs with a dialog
box saying that the "script has stopped responding" type message from
the browser..
Can anyone help?
Thanks
Trev