Sie sind nicht angemeldet.

mauma

Anfänger

  • »mauma« ist der Autor dieses Themas

Beiträge: 24

Wohnort: Lucca - Italy

Beruf: Photographer / Virtual Tour

  • Nachricht senden

1

Freitag, 14. Oktober 2022, 13:16

Javascript action call function inside Krpano action ?

Hello everyone,
I would like to understand if it is possible to call a function inside an object inside a javascript action, the simplified code is this:

Quellcode

1
2
3
4
5
<action name="engine" type="javascript" autorun="onstart">
<![CDATA[  var Move = {  totalmove: 0,	status: true,  start: function () { // some actions  },
        stop: function () { // some actions  }
    };
]]></action>


I should call the functions Move.start () and Move.stop () from krpano actions


I prevent the speech of implementing the script in an external .js file (which works), for some combinations ( panotour) I must necessarily use in the xml file as js action ( always if it is possible )


Thanks a lot *smile*

herrpedro

Fortgeschrittener

Beiträge: 210

Wohnort: Lisbon

Beruf: Programmer/analyst

  • Nachricht senden

2

Freitag, 14. Oktober 2022, 20:09

Hello everyone,
I would like to understand if it is possible to call a function inside an object inside a javascript action, the simplified code is this:

Quellcode

1
2
3
4
5
<action name="engine" type="javascript" autorun="onstart">
<![CDATA[  var Move = {  totalmove: 0,	status: true,  start: function () { // some actions  },
        stop: function () { // some actions  }
    };
]]></action>


I should call the functions Move.start () and Move.stop () from krpano actions


I prevent the speech of implementing the script in an external .js file (which works), for some combinations ( panotour) I must necessarily use in the xml file as js action ( always if it is possible )


Thanks a lot *smile*



hi always used
js, jsget, jscall

https://krpano.com/docu/actions/#js


take a look at webvr.xml file which has a load of javascript code

light_line

Fortgeschrittener

Beiträge: 169

Beruf: krpano freelancer || creating ideas & coding them || krpano developer

  • Nachricht senden

3

Freitag, 14. Oktober 2022, 22:21

Instead of this part of your code:
var Move =.......
use this code:
window.Move =.......
(by this way, you can define the Move object as a global object)
After this change, you can use these codes to run your functions:
jscall(Move.start());
OR
jscall(Move.stop());

I hope it works for you.