loading startup xml from string instead of file

  • In the "Embedding into HTML" documentation the statement swf.addVariable("xml", "pano.xml"); loads the startup xml file. Can I omit that statement and instead load the xml from a string using the loadxml function? For example, I have tried the following code where xmlString contains the content of the pano.xml file and it does not seem to work:

    var swf = createswf("krpano.swf", "krpanoSWFObject", "100%", "100%", "#000000");
    swf.call(loadxml(escape(xmlString)));
    swf.embed("panoDiv");

    What is wrong with the above script? Can someone provide a complete example of loading krpano xml from a string?

    I need to do this because the xml file I am using changes dynamically and I am worried about synchronization problems if it changes before the addVariable statement loads the xml.

  • I answer my own question: I use this initialization function to embed the krpano swf object with xml for initial settings:

    function init() {
    // create krpano swf object (global variable krswf) and load initial xml (non-image settings only)
    // from v1.0.8 krpano documentation
    krswf = createswf("./swfobject/krpano.swf", IDkrswf, "100%", "100%", "#000000");
    krswf.addVariable("xml", "XML/settings.xml");
    krswf.embed("panoDiv");
    }

    Then display successive pano images on demand using this script:

    krpano().call("loadxml(" + escape(xmlString) + ")");

    where xmlString is a Javascript variable containing the xml string for the image and krpano() is this function:

    function krpano() {
    // returns krpano swf object per krpano forum example
    return document.getElementById(IDkrswf); // arg same as second arg in createswf call of init()
    }

    This seems to work.

Participate now!

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