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

Monday, February 12th 2018, 9:14am

javacript caller and resolve?

hi klaus,

javascript in xml actions are described in the docs here...
https://krpano.com/docu/xml/#action.js

but how do you get caller and resolve if you define a krpano action in js itself?
ie. in a js plugin

Source code

1
2
3
4
	krpano.actions.test = function(s){
		krpano.trace(1,"test:"+s);
		// how to get caller?
	}


best, index

2

Tuesday, February 13th 2018, 9:05pm

and another one...
how would i translate something like that into pure js for a plugin?

Source code

1
2
3
    asyncloop(caller.pressed,
        ....
    );


i guess i could use krpano.actions.asyncloop()
but this function expects action code, not js code, right?
is there a way to use such actions like asyncloop with js code?

index

3

Tuesday, February 13th 2018, 9:39pm

Hi,

but how do you get caller and resolve if you define a krpano action in js itself?
That's currently no documented, but there is a 'krpano.actions.actioncaller' variable which points to the caller object (when there is one, otherwise it is null).

A 'resolve' function is not available in that context, but here a simple get() could be used instead - when get() returns null use the name of the variable as value.


is there a way to use such actions like asyncloop with js code?
Sorry, that works only with actions code.
What you could do is either using jscall() in the loop code or adding a custom JS function and calling that in the loop code.

Best regards,
Klaus

4

Wednesday, February 14th 2018, 10:20am

thanks klaus,

all clear...

but i have another one...

Source code

1
screentolayer(get(caller.name), mouse.stagex, mouse.stagey, currentx, currenty);

i guess setting js variables directly doesnt work in such cases, right?

so this translates to:

Source code

1
2
krpano.actions.screentolayer(krpano.actions.actioncaller.name, krpano.mouse.stagex, krpano.mouse.stagey, 'currentx', 'currenty');
krpano.trace(0, krpano.currentx + '/' +  krpano.currenty);

is that correct?


plus one more...
in xml action script you check an unset variable with

Source code

1
if(variable === null, ... );

but a direct use of this in js does not work because in javascript null !== undefined
is it correct that the above line translates to...

Source code

1
if(variable === undefined || variable === null) { ...  }

?

best, index

This post has been edited 5 times, last edit by "indexofrefraction" (Feb 14th 2018, 9:05pm)


Similar threads