Can't call animated png script from external js file

Posted by Tomas on Stack Overflow See other posts from Stack Overflow or by Tomas
Published on 2010-03-21T03:06:31Z Indexed on 2010/03/21 3:11 UTC
Read the original article Hit count: 375

Filed under:
|
|
|
|

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

© Stack Overflow or respective owner

Related posts about animated

Related posts about png