Here is my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Animation Switch</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<script type="text/javascript">
/* <![CDATA[ */
var runDog;
var dog = new Array(6);
var curDog = 0;
for (var imagesLoaded=0; imagesLoaded < 5; ++imagesLoaded) {
dog[imagesLoaded] = new Image();
dog[imagesLoaded].src = "puppy"
+ imagesLoaded + ".gif";
if (imagesLoaded == 5)
runDog = setInterval("runDog()", 100);
}
var pushPin;
var pin = new Array(6);
var curPin = 0;
for (var imagesLoaded=0; imagesLoaded < 5; ++imagesLoaded) {
pin[imagesLoaded] = new Image();
pin[imagesLoaded].src = "pin"
+ imagesLoaded + ".gif";
if (imagesLoaded == 5)
pushPin = setInterval("pushPin()", 100);
}
var choice = document.animation.choice.value;
function check(choice){
if (choice == run)
runDog();
else
pushPin();
}
function runDog(){
if (curDog == 5)
curDog = 0;
else
++curDog;
document.images[0].src = dog[curDog].src;
document.getElementById("play").src = dog[curDog].src;
window.alert ("dog runs now");
}
function pushPin(){
if (curPin == 6)
curPin = 0;
else
++curPin;
document.images[0].src = pin[curPin].src;
document.getElementById("play").src = pin[curPin].src;
}
check()
/* ]]> */
</script>
</head>
<body>
<h1>Change Animation</h1>
<h3>(type run for Puppy and bounce for Push Pin)
<br/>
<form name="animation">
<p>Type: <input name="choice" type="text" size="30" /></p>
<input name="Submit" type="button" value="Change" onclick="check(choice)"/>
</form>
<div id="play" height="72" width="145"></div>
</body>
</html>
Am I even close to getting this to work?

New Topic/Question
Reply


MultiQuote




|