Synthesize an `onload` event

  • If you need to continue doing something in javascript after a pano has finished loading, you can use this little hack:

    Code
    Panorama = {
      onload: function() {
    	alert('finished loading');
      },
    };
    document.getElementById("krpanoSWFObject'").call("set(loading, 0); wait(LOAD); tween(loading, 1, 0.0001, linear, js(Panorama.onload()));");

    From the documentation, the only functions affected by the wait function:

    Quote


    (like lookto, looktohotspot, moveto, zoomto, wait and tween with WAIT as donecall)

    The actionscript is broken down as follows:

    Code
    /* Initialize/Reset a variable to tween */
    set(loading, 0);
    /* Force the next action to be called after the LOAD event fires */
    wait(LOAD);
    /* Set a tween for 1 millisecond (0.0001), and linear tween type (least computation), when done: call js (global javascript function) on Panorama.onload */
    tween(loading, 1, 0.0001, linear, js(Panorama.onload()));

    Hopefully this will help anyone else who had the same problem.

  • Quote

    If you need to continue doing something in javascript after a pano has finished loading,

    How do you mean? Can you give an example?

    whats the difference between your script and events.onloadcomplete(js(Panorama.onload()); ?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!