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

Wednesday, July 18th 2018, 9:57am

Attributes to action and count attributes

Hello,

I've got a little bit stuck, automating some tasks.

I got a hotspot and I want to define some attributes in this hotspot, which I want to send to the action. I know that you can pass variables by setting the scope to "local" and defining args.
The problem is that when I'm doing this, the "addhotspot" which I got in the action doesnt work anymore.

Maybe to understand what I want to achive?

I want to pass custom attributes from a hotspot to an action. This action shoud add some new hotspots to scene. The count of that hotspots should be automatically definied by the count of attributes I'm passing to the action. But I also want to use the attributes in the action to define some options for the new hotspots.

Could you guys give me a hint?

2

Wednesday, July 18th 2018, 12:08pm

https://krpano.com/docu/xml/#action.scope

if your action has a local scope you need to use the caller variable

<hotspot name="..." onclick="myaction();" />

<action name="myaction" scope="local">
trace(caller.name);
set(caller,ath, 0); // reset position
set(caller,atv, 0);
</action>

3

Wednesday, July 18th 2018, 1:30pm

Thanks, thats something I didnt know. But the issue stays, "addhotspot" isnt working when scope is set to local.

4

Wednesday, July 18th 2018, 5:20pm

that i can't believe....

you want to show us your code?

5

Wednesday, July 18th 2018, 6:19pm

This is the action at the moment:

Source code

1
2
<action name="choose_style" scope="local">
	set(hotspot[spot1].anistopped,true);	addhotspot(test2);	hotspot[test2].loadstyle(skin_hotspot_choose_style);		set(hotspot[test2].url, skin/marker_02.png);	set(hotspot[test2].ath, calc(caller.ath-0));	set(hotspot[test2].atv, calc(caller.atv-0));	set(hotspot[test2].linkedscene, BF5_4_02);	tween(hotspot[test2].alpha, 1,1.2);	tween(hotspot[test2].scale, 0.5,0.6);	tween(hotspot[test2].ath, calc(ath-8),0.6);	tween(hotspot[test2].atv, calc(atv-8),0.6);	</action>



And this is the hotspot with the onclick:

Source code

1
<hotspot name="spot1" style="skin_hotspotstyle" url="skin/door_icon.png" depth="1000" onloaded="hotspot_animate();" ath="-132" atv="15" rx="0" rz="0" scale="0.4" onclick="choose_style();"  />


Onclick nothing happends, just the animation stops. When I set scope to "global" its working.

6

Wednesday, July 18th 2018, 6:38pm

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<action name="choose_style" scope="local">
	set(hotspot[spot1].anistopped, true);	
	addhotspot('test2');	
	hotspot[test2].loadstyle('skin_hotspot_choose_style');		
	set(hotspot[test2].url, 'skin/marker_02.png');	
	copy(hotspot[test2].ath, caller.ath);
	copy(hotspot[test2].atv, caller.atv);
	set(hotspot[test2].linkedscene, 'BF5_4_02');	
	tween(hotspot[test2].alpha, 1, 1.2);	
	tween(hotspot[test2].scale, 0.5, 0.6);	
	tween(hotspot[test2].ath, calc(caller.ath - 8), 0.6);	
	tween(hotspot[test2].atv, calc(caller.atv - 8), 0.6);	
</action>


does that work?
(you forgot caller in the last instructions)

This post has been edited 1 times, last edit by "indexofrefraction" (Jul 18th 2018, 10:37pm)


7

Wednesday, July 18th 2018, 10:03pm

Yes, the code looks okay.

Is your krpano version up-to-date?

8

Thursday, July 19th 2018, 10:21am

Great thx, it really was the missing caller in the last instructions.

But I got another question:
Can your remove hotspots by there style? Or do you have to use their name?
I just need to create an action to remove all the hotspots which I created with my "choose_style" action.

toosten

Intermediate

Posts: 480

Location: Berlin

Occupation: freier Software-Entwickler ( HTML, JS, PHP, JSP, Flash, AS3, C++, Java, krpano, ---)

  • Send private message

10

Thursday, July 19th 2018, 11:09am

Thanks for the link. Also I found another way which is working for me.

Thx again @all for your help.