Sie sind nicht angemeldet.

1

Mittwoch, 29. Dezember 2021, 14:05

layer type = "krpano" command from frame

Hello everyone and happy holidays!
Using layer type = "krpano"
I am creating dynamically a frame and a button in it.
In the button on click I assign it like this (js)

Quellcode

1
2
3
4
btn.onclick = function() {
	krpano.actions.trace(55); 	//working
	krpano.actions.test();       	//no working
};

krpano

Quellcode

1
2
3
<action name="test">   
	trace(22);
</action>

The console displays only 55, what is my mistake, please tell me? *question*

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

2

Mittwoch, 29. Dezember 2021, 14:41

Hi,

I think should be like this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
	<action autorun="onstart" type="Javascript">
	<![CDATA[
		krpano.test = function test(t){
			krpano.actions.showlog();
			krpano.trace(1, t);
		}
 	]]>
	</action>

	
	
	<action name="showpano" type="Javascript"><![CDATA[
		var b = krpano.addlayer("btn");
		b.type = "text";
		b.keep = "true";
		b.align = "bottom";
		b.html = "Click Me";
		b.css = "font-family:Helvetica;font-size:14px;";
		b.padding = "10";
		
		b.onclick = "test(55)";
		
	]]></action>


OR

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
	<action name="showpano" type="Javascript"><![CDATA[
		var b = krpano.addlayer("btn");
		b.type = "text";
		b.keep = "true";
		b.align = "bottom";
		b.html = "Click Me";
		b.css = "font-family:Helvetica;font-size:14px;";
		b.padding = "10";
		
		b.onclick = function(){ krpano.call("test(52);"); }
		
	]]></action>	

	<action name="test">
		showlog(true,top);
		trace(%1);
	</action>


Both work for me.
Hope it helps,
Tuuir *thumbsup*

3

Mittwoch, 29. Dezember 2021, 14:52

Quellcode

1
	krpano.actions.test();       	//no working

test is not a javascript function, it cant work that way
also test is not stored in krpano.actions, this is for internal krpano actions only

to call an xml action you would use krpano.call("test();');

4

Mittwoch, 29. Dezember 2021, 14:54

Hi Tuur, great, it works !!! Thanks ! *thumbsup*

5

Mittwoch, 29. Dezember 2021, 15:02

test is not a javascript function, it cant work that way
also test is not stored in krpano.actions, this is for internal krpano actions only

to call an xml action you would use krpano.call("test();');
indexofrefraction, thanks for the explanation!

6

Mittwoch, 29. Dezember 2021, 16:39

Another question like this, if I create a layer
<layer ... type = "krpano" onloaded = "krpano.actions.loadpano ('test.xml');" />
How can I call actions from test.xml?

Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

7

Mittwoch, 29. Dezember 2021, 17:09

My first guess, on phone now, would be:
For example

l.krpano.call("***

Tuur *thumbsup*

8

Mittwoch, 29. Dezember 2021, 17:39

if I write inside the test.xml

Quellcode

1
2
3
4
5
6
7
8
<action autorun="onstart" type="Javascript">
<![CDATA[
	krpano.action_test3 = function test(t){
	krpano.actions.showlog();
	krpano.trace(1,t);
}
 ]]>
</action>

then when doing action_test3(88) inside this test.xml 88 will be displayed in the console of the window, but not in the console of the tour in which this window is

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »San7« (29. Dezember 2021, 17:51)


Tuur

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

Beruf: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Nachricht senden

10

Mittwoch, 29. Dezember 2021, 17:51

yes yes i call action_test3 (88)
»San7« hat folgendes Bild angehängt:
  • е.jpg

11

Mittwoch, 29. Dezember 2021, 23:43

then when doing action_test3(88) inside this test.xml 88 will be displayed in the console of the window, but not in the console of the tour in which this window is

logical, there are separate 2 krpanos, each has its console.
you can do showlog() in the 2nd krpano and then you have 2 consoles ;)

12

Donnerstag, 30. Dezember 2021, 05:05

I need to move an activity to the main tour from the frame.
those. I do not know how to write an action in test2.xml (frame) that would be performed in the main tour, and not in a frame.
test2.xml

Quellcode

1
2
3
4
5
6
7
8
9
10
<hotspot ... onclick="action_test3(88)" />

<action autorun="onstart" type="Javascript" ><![CDATA[	
 krpano.action_test3 = function test(t){	 
   krpano.actions.showlog();	 
   krpano.trace(1,t);

   krpano.call("test();");
 }]]>
</action>
»San7« hat folgendes Bild angehängt:
  • а.jpg

Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von »San7« (30. Dezember 2021, 05:35)


13

Donnerstag, 30. Dezember 2021, 10:35

in your test get the main viewer and trace to it

Quellcode

1
2
3
var krpano1 = document.getElementById('krpanoSWFObject');
krpano1 = krpano1.get('global');
krpano1.trace(1,'hello world');

Dieser Beitrag wurde bereits 5 mal editiert, zuletzt von »indexofrefraction« (30. Dezember 2021, 12:10)


14

Donnerstag, 30. Dezember 2021, 11:25

in your test get the main viewer and trace to it

Hi, indexofrefraction!
Thank you very much, this is what you need, it worked !!! *thumbsup* *thumbsup*

Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

15

Donnerstag, 30. Dezember 2021, 18:06

in your test get the main viewer and trace to it

Quellcode

1
2
3
var krpano1 = document.getElementById('krpanoSWFObject');
krpano1 = krpano1.get('global');
krpano1.trace(1,'hello world');


Hi, indexofrefraction, please, clarify this to me:
How to pass some actions from the new krpano layer?:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//This is the xml of new krpano layer
//...
<layer name="testing_layer"
onclick="test_from_layer();"
align="righttop" keep="true" type="text" html="Action for New Krpano Layer" 
/>

<action name="test_from_layer">
showlog();
trace('hola');
testing();
</action>

<action name="testing" type="Javascript">
<![CDATA[
var krpano1 = document.getElementById('krpanoSWFObject');
krpano1 = krpano1.get('global');
krpano1.call("showlog();");
krpano1.trace(1,'testing..');
krpano1.call("lookto(90,0,100);");
//All of above it works ok
//But this does not work:
krpano1.call("more_actions");
]]>
</action>

<action name="more_actions">
krpano.call("lookto(90,0,100);wait(2);lookto(120,0,100);");
// or separately... :
//lookto(90,0,100); 
//wait(2); 
//lookto(120,0,100);
</action>


Thanks for your help...

16

Donnerstag, 30. Dezember 2021, 18:26

Hi, action name = "more_actions" - is not *question* js, why write krpano.call in it?


this is how it works

Quellcode

1
2
3
4
5
<action name="more_actions">
   lookto(90,0,100); 
  wait(2); 
  lookto(120,0,100);
</action>

Fernando

Fortgeschrittener

Beiträge: 330

Wohnort: Habana, Cuba

Beruf: Architect, Photographer.

  • Nachricht senden

17

Freitag, 31. Dezember 2021, 03:51

Summing the solution up for the communication between Main and Krpano Layer and vice versa

With the help of forum friends, finally this solution works already:
Two .xml, one for the Main and other for the new Krpano layer (xml inside "otherpanos" folder):

xml for Main:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<krpano debugmode="true">

//a- This is the Main

<preview type="grid(cube,100,100,600,0x6688CC,0x000000,0x999999);" />

//b- Text or button for run actions:
<layer name="actions_from_main"
onclick="actions_from_main();"
align="righttop"
keep="true"
type="text"
html="Action from Main To New Krpano Layer" 
/>

//c- Action of text for new krpano layer
<action name="actions_from_main">
layer[newkrpanolayer].krpano.call("lookto(90,0,100);wait(1);lookto(175,0,100);showlog();trace('actions send from main to new krpano layer');");
</action>

//d- Code for making the new krpano layer:
<layer name="newkrpanolayer"
keep="true"
width="500"
height="500"
type="krpano"
onloaded="krpano.actions.loadpano('%VIEWER%/otherpanos/tour.xml');" 
/>
</krpano>


xml for New Krpano Layer:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<krpano debugmode="true">

//a- This is a new krapano layer

<preview type="grid(cube,200,200,600,0x6688CC,0x4466AA,0x999999);" />

//b- Text or button for run actions:
<layer name="actions_from_new_krpano_layer" align="righttop" keep="true" type="text" html="Action From New Krpano Layer To Main" 
onclick="actions_from_new_krpano_layer();"
/>

//c- Action of text for Main:
<action name="actions_from_new_krpano_layer" type="Javascript"><![CDATA[
	var krpano1 = document.getElementById('krpanoSWFObject');
	krpano1 = krpano1.get('global');
	krpano1.call("showlog();lookto(90,0,100);trace('actions send from main to new krpano layer');wait(2);lookto(120,0,100);");	
]]>
</action>
</krpano>


Thanks to all for the help! Happy New Year!
Best regards,
Fernando

Dieser Beitrag wurde bereits 4 mal editiert, zuletzt von »Fernando« (1. Januar 2022, 04:01) aus folgendem Grund: solved for me. Showing the solution. Erasing previous questions not to confuse.


18

Freitag, 31. Dezember 2021, 07:30

Hi Fernando, I just pasted your code into the example with modified "more_actions" action and it works

19

Montag, 3. Juli 2023, 12:51

How i can pass some args to actions_from_new_krpano_layer and than use it in krpano1.call?