starting with a single image, I have three animations I want it to cycle through each time the image is clicked. I created this switch:
function switcher() {
// counts to 4 then resets to 0
x = x+1
if (x>3) {x = 0}
// Fire OFF
if (x == 0) {
// animation code ?
}
// Fire LARGE
if (x == 1) {
// animation code ?
}
// Fire MEDIUM
if (x == 2) {
// animation code ?
}
// Fire SMALL
if (x == 3) {
// animation code ?
}}
1 static state + 3 animated states.
The animation I have uses Paul Irish's requestAnimframe Polyfill then:
function animate()
{
setTimeout(function()
{
requestAnimFrame( animate );
draw();
}, 1000 / 2);
}
function draw()
{
flame=document.getElementById('myimage')
if (flame.src.match("Images/lfire1.png"))
{
flame.src="Images/lfire2.png";
}
else
{
flame.src="Images/lfire1.png";
}
}
each animation is basically this same code but with different Images. The code works when I test it directly but when I copy into the switch it won't work.
I have tried to plug these into my switch using multiple methods and can't seem to get anything to work. any tips? Thank you!