Calling js function on scene load

  • Hi guys,

    I need to call a js function when a scene is completely load.
    Following instructions in other posts, I got it adding

    Code
    <events onloadcomplete="js(my_js_function())"/>

    in every scene defined in .xml file.

    But it's not exactly what i need.

    I need to do it in a js function. I mean, when tour starts, a js function is called and i want to add something like

    Code
    krpano.set("scene[scene_name].events.onloadcomplete",my_js_function());


    Obviously this code doesn't work, any ideas on how to do this?

  • Hi,

    direct access to scene content is not possible - the whole <scene> content is stored unparsed as scene[name].content and will be only be parsed and loaded when loading the scene.

    But using a global events should already work - why can't this be used?
    The event would need to be defined only once outside any scene.

    Either by using the global events or by using a 'named' <events> element and keep=true - e.g.

    Code
    <krpano>
       <events name="myevents" onloadcomplete="js( ... );" keep="true" />
       <scene ...>
       </scene>
       <scene ...>
       </scene>
       ...
    </krpano>

    Best regards,
    Klaus

  • I needed a js way to do that, but ty anyway.

    I solved this way:

    Code
    krpano = document.getElementById("krpanoSWFObject");krpano.set("events.onloadcomplete","js(my_js_function())");krpano.set("events.keep",true);

    now my_js_function is called everytime a scene is loaded.

    Ty

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!