Perform action every time a scene is loaded completely

  • Hi,

    I'm creating a rather large virtual tour with 25 scenes in it. In order to shorten the loading times I decided to preload the source images for every linked scene using this workaround. E.g. when a user is in scene 2, scene 1 and 3 have to preload.

    I used the following code in every scene:
    <events onloadcomplete="preloadpano(); set(event.onloadcomplete,null);>
    <action name="preloadpano">...</action>

    ... but it only works for the first scene. I think this is because onloadcomplete works only once. Is there any other way to do this?

    I definitely want to preload after the current scene is loaded completely, otherwise the preloading slows down the loading of the current scene.

  • Hi,

    ... but it only works for the first scene. I think this is because onloadcomplete works only once. Is there any other way to do this?

    it works only for the first scene, because in the "onloadcomplete" was set to 'null' after the first call,
    see this code:

    Code
    set(event.onloadcomplete,null);

    just remove that,
    or set separate <event> tags in every <scene> tag,

    best regards,
    Klaus

  • Hi,

    it should be in every <scene> but with the current version there is also an other possibility - using 'named' <event> elements - these elements will be removed automatically when loading a new pano/scene,

    so define in every <scene> just: (so no need to set onloadcomplete back to null)

    Code
    <events name="sceneevents" onloadcomplete="..." />

    best regards,
    Klaus

  • Hi all,

    I am using the preload procedure as described in the first post. It does work, but I found that it can be interupted by an action and the complete preload then seems to be lost.

    Here is the situation where I try to use it: I made a tour for a car dealer who has 3 different showrooms.
    It is possible to look round in every car in every showroom.
    When loading a showroom, I call the preload like this and that seems to work fine as long as it is not interupted:

    Code
    <events onloadcomplete="preloadpano2(); preloadauto1(); preloadauto2(); preloadauto3()"/>


    But if I click on a hotspot to load a new scene (like any car in that showroom) before all images have completely preloaded I seem to loose all of them.
    And returning to the showroom from the car does not start the preload again as I had hoped.

    I wonder if I am doing something wrong, of if there is a better solution.

    Thanks for any help!

    Ton

  • Thanks Klaus,

    I finally found some time to do a number of tests, as I was not sure where to place the 'keep'.

    It seems that the 'keep' does work like this, but I still have the problem that the preload is terminated when I click on a hotspot before all has been loaded.

    My code for the preload looks like this:

    And this is how I embedded the preload command in the scene:

    I have only made a preload command for the first three cars in this test: http://www.pro4pics.com/test/den_hartog/tour.html

    Thanks for having a look at it!

    Ton

  • Hi,

    add the keep=true in the preloadimage action for the preloaded image:

    Code
    <action name="preloadimage">
      <!-- 1. parameter = internal ID,  2. parameter = url -->
      addplugin(pre_%1);
      set(plugin[pre_%1].visible, false);
      set(plugin[pre_%1].keep, true);
      set(plugin[pre_%1].onloaded, trace(preload %2 done);removeplugin(pre_%1) );
      set(plugin[pre_%1].url, %2);
      trace(starting preloading %2);
    </action>

    best regards,
    Klaus

Participate now!

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