Hello,
Chip Chapin has a JavaScript "Eiffel Tower" animation example at:
I know just enough about JavaScript (and programming in general) to get myself into trouble. I wanted to create an animation similar to the Eiffel Tower one at his website. So, I copied and pasted the code from the Eiffel Tower page into my editor and deleted all the non-relevant text, etc. Then, I took five .jpg images to test the process, renamed them anim0.jpg, anim1.jpg, etc., created the image exampleA01-anim0.jpg, and placed the images in the same folder as the .html page. Then, I changed all references from .gif to .jpg in the code.
Below is the resulting code. When I test the animation, the exampleA01-anim0.jpg appears, but the animation doesn't work. Any ideas on what I need to do differently to make it work? Thanks!
Bill
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
JavaScript Example A-1 -- Image Animation w/Speed Control
</title>
<script language="JavaScript">
function SymError()
{
return true;
}
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
</script>
<script type="text/javascript" language="JavaScript1.2">
anims = new Array(5);
var frame = 0;
var timeout_state = null;
function imageLoad() {
for(var i = 0; i<5; i++) {
anims = new Image();
anims.src = "exampleA01-anim" + i + ".jpg";
}
}
function animator() {
document.animImage.src = anims[frame].src;
frame = (frame + 1);
if(frame >= 5) {
frame = 0;
}
timeout_state = setTimeout("animator()", document.animForm.animPace.value);
}
function buttonCheck() {
if(document.animForm.animButton.value == "Start") {
document.animForm.animButton.value = "Stop";
animator();
} else {
document.animForm.animButton.value = "Start";
clearTimeout(timeout_state);
timeout_state = null;
}
}
</script>
</head>
<p>
<img src="exampleA01-anim0.jpg" name="animImage"
</p>
<form name="animForm">
<input type="button" value="Start" name="animButton"
onclick="buttonCheck()"><input type="text" value="250"
name="animPace">milliseconds
</form>
<br>
<br>
</body>
</html>
<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;
function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}
function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}
SymRealOnLoad = window.onload;
window.onload = SymOnLoad;
//-->
</script>
Chip Chapin has a JavaScript "Eiffel Tower" animation example at:
I know just enough about JavaScript (and programming in general) to get myself into trouble. I wanted to create an animation similar to the Eiffel Tower one at his website. So, I copied and pasted the code from the Eiffel Tower page into my editor and deleted all the non-relevant text, etc. Then, I took five .jpg images to test the process, renamed them anim0.jpg, anim1.jpg, etc., created the image exampleA01-anim0.jpg, and placed the images in the same folder as the .html page. Then, I changed all references from .gif to .jpg in the code.
Below is the resulting code. When I test the animation, the exampleA01-anim0.jpg appears, but the animation doesn't work. Any ideas on what I need to do differently to make it work? Thanks!
Bill
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>
JavaScript Example A-1 -- Image Animation w/Speed Control
</title>
<script language="JavaScript">
function SymError()
{
return true;
}
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
</script>
<script type="text/javascript" language="JavaScript1.2">
anims = new Array(5);
var frame = 0;
var timeout_state = null;
function imageLoad() {
for(var i = 0; i<5; i++) {
anims = new Image();
anims.src = "exampleA01-anim" + i + ".jpg";
}
}
function animator() {
document.animImage.src = anims[frame].src;
frame = (frame + 1);
if(frame >= 5) {
frame = 0;
}
timeout_state = setTimeout("animator()", document.animForm.animPace.value);
}
function buttonCheck() {
if(document.animForm.animButton.value == "Start") {
document.animForm.animButton.value = "Stop";
animator();
} else {
document.animForm.animButton.value = "Start";
clearTimeout(timeout_state);
timeout_state = null;
}
}
</script>
</head>
<p>
<img src="exampleA01-anim0.jpg" name="animImage"
</p>
<form name="animForm">
<input type="button" value="Start" name="animButton"
onclick="buttonCheck()"><input type="text" value="250"
name="animPace">milliseconds
</form>
<br>
<br>
</body>
</html>
<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;
function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}
function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}
SymRealOnLoad = window.onload;
window.onload = SymOnLoad;
//-->
</script>