Can't call animated png script from external js file
- by Tomas
Hello,
I'm trying to put an animated PNG dinamicaly from external .js file. First I found a simple animated png solution, which draws an animation wherever you put the code within tags, but now it looks like I don't know how to call the function properly from external file.
The script is from www.squaregoldfish.co.uk/software/animatedpng, and it looks something like this:
<script type="text/javascript" src="animatedpng.js"></script>
<div id="pnganim" align="center">
<script>
fishAnim = new AnimatedPNG('fish', 't01.png', 3, 100);
fishAnim.draw(false);
</script>
</div>
Now, I'm trying to call this from external.js file and jquery:
function addFish(){
$('#pnganim').html('<script type="text/javascript" src="animatedpng.js" />');
fishAnim = new AnimatedPNG('fish', 'fish01.png', 3, 100);
myFish = fishAnim.draw(false);
$('#pnganim').append(myFish);
}
... and it's not working. After I click a button that calls the addFish function, it opens only the first frame on a blank page.
What am I doing wrong here?
Thanks