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.

lonelyelk

Beginner

  • "lonelyelk" started this thread

Posts: 20

Location: Moscow

  • Send private message

1

Friday, October 16th 2015, 3:39pm

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?

spacerywirtualne

Professional

Posts: 872

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

2

Friday, October 16th 2015, 4:18pm

Source code

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


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

facebook page :: facebook group :: youtube

cms4vr team *thumbsup*

lonelyelk

Beginner

  • "lonelyelk" started this thread

Posts: 20

Location: Moscow

  • Send private message

3

Friday, October 16th 2015, 5:52pm

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?

spacerywirtualne

Professional

Posts: 872

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

4

Friday, October 16th 2015, 9:28pm

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.

Source code

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:

Source code

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
You own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: facebook group :: youtube

cms4vr team *thumbsup*

lonelyelk

Beginner

  • "lonelyelk" started this thread

Posts: 20

Location: Moscow

  • Send private message

5

Saturday, October 17th 2015, 1:44pm

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.