Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

  • »nathanfjohnson« ist der Autor dieses Themas

Beiträge: 11

Wohnort: Calgary Canada

Beruf: Student

  • Nachricht senden

1

Donnerstag, 9. Juli 2009, 07:04

get the current xml file name. and calling external functions in the xml

I can't seem to figure out the get(variable) to get the name of the current xml file. Does someone know if this is possible?
it would also work for me to be able to use an action in the panorama xml to send the filename with a function. Could I get help with that syntax?

Thank you

Graydon

Profi

Beiträge: 614

Wohnort: Texas

Beruf: Industrial gas turbine services.

  • Nachricht senden

2

Freitag, 10. Juli 2009, 09:22

Here's a quick sample...

http://marlincreek.com/demo/xml_name/

Assuming I understood your request correctly.

When the grid loads up, press "O" (not zero) to get the info box to show up... you should see

Quellcode

1
2
3
4
5
INFO: krpano 1.0.8 beta 7 (build 2009-04-08)
INFO: Flashplayer WIN 10,0,22,87 PlugIn
INFO: registered to: Marlin Creek
INFO: --------------
INFO: my current xml is marlin_creek.xml


I used the onstart action to set a variable to the name of the xml... which has to be explicitly defined. I do not know of an automatic way. Once the variable is set... I call a js function that is defined in the html... and it defines a js variable from the xml / krpano variable and then sends it back to krpano in the trace function.

Here are the relevant pieces of code.

first, the onstart item...

Quellcode

1
onstart="set(current_xml, marlin_creek.xml); js(show_name());

... this could be called from different areas... The click me buttom references the same js function.

The html / js stuff...

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<script type="text/javascript">
// <![CDATA[
	
	function krpano() 
	{
		return document.getElementById("panox");
	}

	function show_name()
	{

		krpano().call("trace(--------------)");

		var my_file =( krpano().get("current_xml") );
		krpano().call("trace(my current xml is " + my_file + ")");

	}

// ]]>
</script>


The "panox" reference in the "return document..." is based upon what I call the embedded swf. I use swfobject 2.x and here's the snippet from the attributes item...

Quellcode

1
2
3
4
			var attributes = {
				id: "panox",
				name: "apano"
			};


Graydon

edit: There are a couple of different ways to define some variables... unfortunately I don't remember them right now. Hopefully Klaus or others will chime in with any alternate methods.

edit2: Hope this helps... this shows that you can pass the info to js... from there, you can do whatever you'd like. I just passed it back through in the trace function to show it's possible.

  • »nathanfjohnson« ist der Autor dieses Themas

Beiträge: 11

Wohnort: Calgary Canada

Beruf: Student

  • Nachricht senden

3

Freitag, 10. Juli 2009, 20:16

Thank you

Thanks for all your info, I'll have to read over it a few times but it looks like that's what I am looking for.
I'm very impressed with the helpfulness of everyone on these forms.

4

Montag, 13. Juli 2009, 08:54

Hi,

there is also a other way to get the current xml (sorry, not documented yet )
there are two variables that can be accessed with get():
  • xml.url - the url of the current xml file
  • xml.content - the content of the current xml file as string

e.g. to call from javascript:

Quellcode

1
var xmlurl = krpano().get("xml.url");


best regards,
Klaus

Ähnliche Themen