You are not logged in.

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

1

Wednesday, December 15th 2010, 9:30pm

ondown move hotspot

Hi,

Im trying to create a button which hovers above the hotspot, while pressed it should drag the hotspot. So somehow I need to

ondown, mousex -> ath.

Source code

1
2
3
4
5
6
<hotspot name="tiny_bar" keep="true" visible="true" alpha="0.8" url="tinybar_bg.png" enabled="true" handcursor="false" ox="-50" oy="-50" zorder="1000" />
<plugin name="tiny_bar_move" parent="hotspot[tiny_bar]" keep="true" alpha="1" visible="true" url="move.gif" enabled="true" x="22" y="0" width="16" height="16" align="center" zorder="1001" 
ondown="
screentosphere(get(mouse.x),get(mouse.y),tmp_h,tmp_v);
set(hotspot[tiny_bar].ath,get(tmp_h));
set(hotspot[tiny_bar].atv,get(tmp_v));" />


but it jumps all over the place.

Any idea?

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

2

Monday, December 20th 2010, 11:26am

no one got a clue?:(

3

Monday, December 20th 2010, 1:20pm

Hi,

the screentosphere and spheretoscreen actions are needing variables as parameters (not values),

so try:

Source code

1
screentosphere(mouse.x,mouse.y,tmp_h,tmp_v);


best regards,
Klaus

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

4

Monday, December 20th 2010, 3:38pm

Ok that worked, only the ondown event only fires once, so it's not really a "drag". So I binded an onhove to the ondown event. But it still doesnt work

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<hotspot name="tiny_bar" keep="true" visible="true" alpha="0.8" url="tinybar_bg.png" enabled="true" handcursor="false" ox="-50" oy="-50" zorder="1000" />
<plugin name="tiny_bar_delete" parent="hotspot[tiny_bar]" keep="true" alpha="1" visible="true" url="delete.png" enabled="true" x="1" y="0"  width="16" height="16"  align="center" zorder="1001" onclick="js(deleteHotspot())" />
<plugin name="tiny_bar_save" parent="hotspot[tiny_bar]" keep="true" alpha="1" visible="true" url="save.gif" enabled="true" x="-20" y="0" width="16" height="16" align="center" zorder="1001" onclick="js(updateHotspot())"/>
<plugin name="tiny_bar_move" parent="hotspot[tiny_bar]" keep="true" alpha="1" visible="true" url="save.gif" enabled="true" x="22" y="0" width="16" height="16" align="center" zorder="1001" 
ondown="
screentosphere(mouse.x,mouse.y,tmp_h,tmp_v);
set(onhover,
	set(hotspot[hotspot_196].ath,get(tmp_h));
	set(hotspot[hotspot_196].atv,get(tmp_v));
	set(hotspot[tiny_bar].ath,get(tmp_h));
	set(hotspot[tiny_bar].atv,get(tmp_v));
	trace(get(tmp_v));
)" 
onup="set(onhover,)"


Is there a way to simulate the flash stopDrag and startDrag within krpano? or javascript would be fine to, I tried to bind an onMousedown event on the hotspot object, but it seems krpano().get doesnt return an object, just a value (string).

This post has been edited 1 times, last edit by "Zephyr" (Jan 8th 2011, 1:08pm)


5

Tuesday, December 21st 2010, 11:34am

Hi,

here a simple piece of code for dragging an hotspot:

Source code

1
2
ondown="set(dragging,true); draghotspot();"
onup="set(dragging,false);"


and

Source code

1
2
3
4
5
6
<action name="draghotspot">
  if(dragging, 
	screentosphere(mouse.x,mouse.y,ath,atv);
	delayedcall(0,draghotspot());
	);
</action>


a variable - "dragging" - will be set on mouse down, and then the "draghotspot" action will be constantly called to set the ath/atv coordinates from the mouse position as long as that variable is set, and on mouse up this "dragging" variable will be simply set to false to stop that updating,

best regards,
Klaus

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

6

Tuesday, December 21st 2010, 12:21pm

Awesome Klaus! That did the trick! :)

Curious, why is the delayedcall of 0 seconds necessary? To enforce a "lag" in the loop? Wouldnt the calculations performed in the action not enforce the necessary delay? or is the loopcall asynchronous instead of sequential

7

Thursday, December 23rd 2010, 11:29am

Hi,

Flash itself is synchronous, there is no real 'background' processing or so,
it works sequentially like that:
executing code -> rendering frame -> executing code -> rendering frame -> ...

the delayedcall(0, ..) is used to call that code later as soon as possible again (in the next flash frame refresh),
the normal krpano actions that were called were also executed/processed sequentially all at once in the 'executing code' step,
and when all code was done, the next frame was rendered,

without delayedcall that would be an endless loop, it will never leave the 'executing code' step,

only the blocking actions like wait/lookto/looktohotspot/moveto/zoomto are a special in that way,
they stop then action execution/processing, do their job and then continue the the actions processing,

the tween() action is also a special case, then call it will start and then processed every frame to update the value,

best regards,
Klaus

VN2009

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

8

Thursday, December 30th 2010, 3:29pm

could this be modified to work with plugins also? say i have my map in the upper right could we give the user the option to click, move the map to the bottom corner and leave it there?

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

9

Thursday, December 30th 2010, 6:02pm

Yeah plugins would work to. I have made a bar (plugin) with buttons on it (alsoo defined as plugins) when you press and hold the move button, a linked hotspot moves + the bar with the buttons in it.

instead of translating x/y coordinates to spherical, you could just use the coordinates, but with an offset (because the button is somewhere else then the map)

<action name="draghotspot">
if(dragging,
add(tmp_x, get(mouse.x), 50);
add(tmp_y, get(mouse.x), 50);
set(plugin[map].y, tmp_y);
set(plugin[map].x, tmp_x);
delayedcall(0,draghotspot());
);
</action>

It takes some time to set up the plugins, and link the children, so you only move the parent map but it works.

VN2009

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

10

Friday, January 7th 2011, 8:28pm

Zepher this code is not working for me. When i set it to a plugin and click on it the plugin jumps to the bottom right corner. i found the error in the add(tmp_y, get(mouse.Y), 50); the Y was an X fixed that and it still does not work. I want to click in my map move it to another corner and leave it there. Any ideas what is not working?

VN2009

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

11

Friday, January 7th 2011, 9:16pm

i tried this to no avail.

<action name="draghotspot">
if(dragging,
copy(plugin[snd].x, get(mouse.x));
copy(plugin[snd].y, get(mouse.y));
delayedcall(0,draghotspot());
);
</action>

VN2009

Professional

Posts: 1,336

Location: Duluth MN

  • Send private message

12

Friday, January 7th 2011, 11:12pm

got it! now the users can click and move the textfield and map anywhere in the tour and leave it there!