You are not logged in.

mauma

Beginner

  • "mauma" started this thread

Posts: 24

Location: Lucca - Italy

Occupation: Photographer / Virtual Tour

  • Send private message

1

Friday, October 14th 2022, 1:16pm

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:

Source code

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

Intermediate

Posts: 210

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

2

Friday, October 14th 2022, 8:09pm

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:

Source code

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

Intermediate

Posts: 169

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

  • Send private message

3

Friday, October 14th 2022, 10:21pm

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.