Sie sind nicht angemeldet.

1

Mittwoch, 18. Juli 2018, 09:57

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

Mittwoch, 18. Juli 2018, 12:08

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

Mittwoch, 18. Juli 2018, 13:30

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

4

Mittwoch, 18. Juli 2018, 17:20

that i can't believe....

you want to show us your code?

5

Mittwoch, 18. Juli 2018, 18:19

This is the action at the moment:

Quellcode

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:

Quellcode

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

Mittwoch, 18. Juli 2018, 18:38

Quellcode

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)

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »indexofrefraction« (18. Juli 2018, 22:37)


7

Mittwoch, 18. Juli 2018, 22:03

Yes, the code looks okay.

Is your krpano version up-to-date?

8

Donnerstag, 19. Juli 2018, 10:21

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.

10

Donnerstag, 19. Juli 2018, 11:09

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

Thx again @all for your help.