You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, August 3rd 2010, 3:00pm

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.

2

Wednesday, August 4th 2010, 5:40pm

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.

3

Tuesday, September 14th 2010, 11:31am

I'm not sure if I hadn't misunderstood your problem but I'm loading all xmls from DB with mysql...(this way I can easily edit xml code via simplexml...) - in htaccess I have this line:
#RewriteRule ^(.*)\.xml$ http://../redirect.php?file=$1 [R,NC]

and redirect.php will gave krpano the xml with last version and matching id...