3

I use google converted swiffy script like this

var stage = new swiffy.Stage(document.getElementById('swiffycontainer'),swiffyobject);
stage.start();

My point is I want to do the action after the animation end. but I don't know how to track the frame on swiffy object.

this is my work before asking

  • I put start method after page is loaded on

    $(document).ready

    $(window).load

    window.onload =

and track the time (random test to reach the last frame) with

setTimeout(callAtEnd(),10000);

result: not work; like it count the time when page is rendering, not after complete rendered

  • let it start method and put setTimeout on load (should count after complete rander

result: not work either

Please help or give other solution to do.

Many thanks.

user1128331
  • 707
  • 4
  • 10
  • 20

2 Answers2

4

$(document).ready() will fire when the DOM is ready, but before the browser has finished loading all external resources.

window.onload will fire when the browser has finished loading all external resources. However, there may still be other operations being performed asynchronously.

Neither of these will give you a 100% accurate timing with relation to the swiffy timeline.

What you would need to do is add some ActionScript that will fire when the animation is complete. Since Swiffy only supports a subset of Actionscript, the simplest way is to have your Flash call a Javascript function by using the getURL() function, such as:

getURL("javascript:animationIsComplete();");

This way, Swiffy can call your completion handler directly without any need for timing page loads.

See Is there any way to detect when a Swiffy animation has completed?

Community
  • 1
  • 1
nullability
  • 10,545
  • 3
  • 45
  • 63
  • Thank you for response, can I ask more details about the code? So I should put the code (getURL) like that your post on the flash right? where I put the action to do when the flash is end? Is it animationIsComplete right? Thank you. – user1128331 Sep 21 '13 at 05:32
3

You can call it in two ways:

document.onload=function() {}

window.onload = function() {}

The best to use is document.onload because it separates content structure from code, but it all depends on the amout of javascript you have.

If you want to use jQuery its:

$(document).ready() {}
António Regadas
  • 714
  • 4
  • 11
  • Thank you for comment. window.onload and $(document).ready() [} do not give the action that I wish for (problem on time loading); So I will take the document.onload to test. – user1128331 Sep 21 '13 at 05:34