Sie sind nicht angemeldet.

1

Freitag, 16. Oktober 2015, 15:39

Dynamic style assignment on a hotspot created in an action?

addhotspot(test);
set(hotspot[test].style, stylename);

seems to have no effect on said hotspot style. Style seems to work only when assigned statically in xml. Is there a way to apply a style by name on a newly created hotspot via action?

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

2

Freitag, 16. Oktober 2015, 16:18

Quellcode

1
2
addhotspot(test);
hotspot[test].loadstyle(stylename);


Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

3

Freitag, 16. Oktober 2015, 17:52

Thank you very much!
I there any place where these methods and functions are documented?Also I find that this approach messes up hotspots zorder. In flash version setting style zorder attribute seems to help, but in html5 version the order seems to be different if you add hotspots without style, load hotspots from action tag of from javascript using krpano.call method. And no way to reorder hotspots afterwards.
Adding hotspots without style always sets visible zorder in the order of adding: last on top. But when using loadstyle this order is broken. And it is broken differently depending on which version (swf, html5) you use and is it js or action interface. How can i fix it? Is it because javascript krpano.call is asynchronous and action is synchronous?

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

4

Freitag, 16. Oktober 2015, 21:28

I have no experience in adding hotspots by using javascript.

I had no problems with zorder property (Flash and HTML5).

Set dynamically zorder order by using variable.

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<krpano inc_hs="10">
	
	<style name="stylename" url="..." width="" height="..."  />
	
	<action name="load_hotspots">
		addHs(test1,stylename,0,0);
		addHs(test2,stylename,10,0);
		addHs(test3,stylename,20,0);
	</action>
	
	<action name="addHs">
		addhotspot(%1);
		hotspot[%1].loadstyle(%2);
		copy(hotspot[%1].zorder, inc_hs);
		set(hotspot[%1].ath, %3);
		set(hotspot[%1].atv, %4);
		inc(inc_hs);
	</action>
	
</krpano>



In javascript this would probably like this:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<script>
// <![CDATA[

	function addHs(a,b,c,d)
	{
		var krpano = document.getElementById("krpanoObject");
		var inc_hs = krpano.get('inc_hs');
	  
		krpano.call("addHs("+a+","+b+","+c+","+d+","+inc_hs+");");

	}
	
	addHs(test1,stylename,0,0);
	addHs(test2,stylename,20,0);

// ]]>
</script>


but as I wrote I have no experience in javascreept...

Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

5

Samstag, 17. Oktober 2015, 13:44

Thank you again!

I figured it out. I had an action that was adding hotspots if they were missing. And somehow I was getting different results on if(hotspot[name] === null, ...) depending on if action was called from another action or from javascript. So zorder was not applied correctly.