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

Friday, October 1st 2010, 10:25pm

Button to move plugin in X pixels increments (on each click)

Hi Guys,



I'd like to create a button that moves a plugin in 160 px each time I click on it.
Is it possible?



The only thing I made is the change of the plugin position with this code:



Source code

1
onclick="tween(plugin[img01].x, 150, distance(300,0.7), linear);"




But it only moves to another position on the first click. I need to be an every click change of that amount (150px)


I give up to try to make it! Just browsed the forum and couldn't find it though.

Could I have your help please???

Thanks,
Daniel

2

Friday, October 1st 2010, 10:59pm

As in add(plugin[img01].x,100); ? (not tested)

3

Friday, October 1st 2010, 11:17pm

Thanks,

That worked, BUT, it's like a SET not Tween attribute.
Do you know how can I have a smooth transition?

Thanks!!!!!!!!!!!!
Daniel

4

Friday, October 1st 2010, 11:23pm

I never used tween, so I don't know very well how it works, but there seems to be an argument for running an action when the tween is done, so if the new position is not getting saved you could try just plugging the add() call in there...

5

Friday, October 1st 2010, 11:29pm

Don't know if I understood....



The Tween makes the movement appear.
Like... Go from here to there in 1 second.

The SET makes a plugin that is here, appear there in a click.

Anyone know if it's possible to tween every 150px in each "onclick"??

Thank you again!!
Daniel

6

Friday, October 1st 2010, 11:38pm

Try this piece of code

Source code

1
onclick="if(x GT 0, inc(x, 150,1000,20));"


1000 is the maximum position 1000 px
20 is the minimum position 20px, the button come back at this place ;-)

7

Friday, October 1st 2010, 11:59pm

Hi,


Thank you Job.1



with this code, I have to input it on the plugin that will change position.
The situation is a Button that changes a plugin in that 150px increment, with smooth (rolling like) movement.

But great to have you code!! Just thinking how to apply it correctly!!

Thanks!!

8

Saturday, October 2nd 2010, 12:06am

Source code

1
onclick="if(plugin[yourplugin].x GT 0, inc(x, 150,1000,20));"

9

Saturday, October 2nd 2010, 12:30am

didn't work. Same behavio as last code.
The button moves, inspite of the other plugin.

Any Idea? :)

10

Saturday, October 2nd 2010, 12:40am

Replace inc(x with inc(plugin[yourplugin].x

Time to start analyzing the code a little!

11

Saturday, October 2nd 2010, 1:00am

Yes , I try and it's working

Source code

1
if(plugin[yourplugin].x GT 0, inc(plugin[yourplugin].x, 150,1000,20));

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

12

Saturday, October 2nd 2010, 1:03am

Hi,

Here an exemple using tween:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<krpano version="1.0.8" onstart="" >

	<!-- use only a grid preview pano to save download space ;-) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />
	
	<style name="buttonstyle"
	   	url="%SWFPATH%/plugins/textfield.swf" children="false"
	   	width="120" height="22"
	   	css="p{color:#000000; font-family:Arial; font-weight:bold; font-size:14; margin-left:5; margin-right:5; text-align:center; }" 
	   	backgroundcolor="0xFFFFFF" roundedge="5" shadow="1" borderwidth="0" glow="4" glowcolor="0xFFFFFF" 
	   	visible="false" 
	   	onover="tween(alpha,0.7,distance(0.3,0.2));" 
	   	onout="tween(alpha,1.0,distance(0.3,0.2));" 
	   	onloaded="set(alpha,0);set(textblur,15);set(blur,15); set(visible,true); tween(alpha,1,0.3); tween(textblur,0,0.3); tween(blur,0,0.3);"
	   	/>	
	
	<plugin name="p1" keep="true" style="buttonstyle"
	    	html="[p]click me[/p]"
	    	align="bottom" x="0" y="75"
	    	onclick="move_by(get(name),100);"
	    	/>   
	
	<action name="move_by">
		copy(temp,plugin[%1].x);
		inc(temp, %2,500,-500);
		tween(plugin[%1].x, get(temp));
	</action>
		
</krpano>


Hope this help...

SAlut.

13

Saturday, October 2nd 2010, 1:04am

Oui c'est aussi une soluce

Yes is another solution ;-) *thumbsup*

14

Saturday, October 2nd 2010, 1:15am

Hi,
It worked now, but it's like the other code:



Source code

1
add(plugin[img01].x,180);




It jumps to the other location.
And... the last value that sets the end position is not working.

Well.. no problem by now.
It's working ok, instead i'd love to have a tween (scrolling) movement.




EDIT: Ooops. Sorry.. I'll look the tween code now!!


Thanks,
Daniel

15

Saturday, October 2nd 2010, 1:35am

On the Michel's code

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<krpano version="1.0.8" onstart="" >

	<!-- use only a grid preview pano to save download space ;-) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />
	
	<style name="buttonstyle"
	   	url="%SWFPATH%/plugins/textfield.swf" children="false"
	   	width="120" height="22"
	   	css="p{color:#000000; font-family:Arial; font-weight:bold; font-size:14; margin-left:5; margin-right:5; text-align:center; }" 
	   	backgroundcolor="0xFFFFFF" roundedge="5" shadow="1" borderwidth="0" glow="4" glowcolor="0xFFFFFF" 
	   	visible="false" 
	   	onover="tween(alpha,0.7,distance(0.3,0.2));" 
	   	onout="tween(alpha,1.0,distance(0.3,0.2));" 
	   	onloaded="set(alpha,0);set(textblur,15);set(blur,15); set(visible,true); tween(alpha,1,0.3); tween(textblur,0,0.3); tween(blur,0,0.3);"
	   	/>	
	
	<plugin name="p1" keep="true" style="buttonstyle"
	    	html="[p]click me[/p]"
	    	align="bottom" x="0" y="75"
	    	onclick="move_by(get(name),200);"
	    	/> 
	
	<plugin name="move" keep="true" style="buttonstyle"
	    	html="[p]I move[/p]"
	    	align="bottom" x="0" y="150"
	    	onclick="move_by(get(name),200);"
	    	/>    
	
	<action name="move_by">
		copy(temp,plugin[move].x);
		inc(temp, %2,500,-500);
		tween(plugin[move].x, get(temp));
	</action>
		
</krpano>


on clicking the other plugin move, you have 2 différents solution ;-)

16

Saturday, October 2nd 2010, 1:36am

On the Michel's code

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<krpano version="1.0.8" onstart="" >

	<!-- use only a grid preview pano to save download space ;-) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />
	
	<style name="buttonstyle"
	   	url="%SWFPATH%/plugins/textfield.swf" children="false"
	   	width="120" height="22"
	   	css="p{color:#000000; font-family:Arial; font-weight:bold; font-size:14; margin-left:5; margin-right:5; text-align:center; }" 
	   	backgroundcolor="0xFFFFFF" roundedge="5" shadow="1" borderwidth="0" glow="4" glowcolor="0xFFFFFF" 
	   	visible="false" 
	   	onover="tween(alpha,0.7,distance(0.3,0.2));" 
	   	onout="tween(alpha,1.0,distance(0.3,0.2));" 
	   	onloaded="set(alpha,0);set(textblur,15);set(blur,15); set(visible,true); tween(alpha,1,0.3); tween(textblur,0,0.3); tween(blur,0,0.3);"
	   	/>	
	
	<plugin name="p1" keep="true" style="buttonstyle"
	    	html="[p]click me[/p]"
	    	align="bottom" x="0" y="75"
	    	onclick="move_by(get(name),200);"
	    	/> 
	
	<plugin name="move" keep="true" style="buttonstyle"
	    	html="[p]I move[/p]"
	    	align="bottom" x="0" y="150"
	    	
	    	/>    
	
	<action name="move_by">
		copy(temp,plugin[move].x);
		inc(temp, %2,500,-500);
		tween(plugin[move].x, get(temp));
	</action>
		
</krpano>


on clicking the other plugin move, you have 2 différents solution ;-)

17

Saturday, October 2nd 2010, 2:06am

WOW!!
LOVED THAT!! :)

I have 2 arrows (left and right)



I'm getting confused with these values....

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<plugin name="scrollthumbsleft" url="%SWFPATH%/thumbs-arrow-left.png"
         parent="background"
         align="center top"
         x="120"
         y="30"
   zorder="101"
         rotate="0"
   scale="1"
         onclick="move_by_left(get(name),180);"
         onup=""
         /> 
 
<plugin name="scrollthumbsright" url="%SWFPATH%/thumbs-arrow-right.png"
         parent="background"
         align="center top"
         x="160"
         y="30"
   zorder="101"
         rotate="0"
   scale="1"
         onclick="move_by_right(get(name),-180);"
         onup=""
         /> 
 
<action name="move_by_left">
  copy(temp,plugin[img01].x);
  inc(temp, %2,225,315);
  tween(plugin[img01].x, get(temp));
 </action>
 
   <action name="move_by_right">
  copy(temp,plugin[img01].x);
  inc(temp, %2,225,315);
  tween(plugin[img01].x, get(temp));
 </action>




The original position of the img01 plugin is 315

The increment is of 180 px



I want to let user make only 4 clicks to the right.

Things are messy there..

Thaaaaaaaaaaaaaaaanks!!!
Daniel

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

18

Saturday, October 2nd 2010, 3:00am

Hi Daniel,

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<krpano version="1.0.8" onstart="" >

	<!-- use only a grid preview pano to save download space ;-) -->
	<preview type="grid(cube,16,16,512,0xCCCCCC,0xFFFFFF,0x999999);" details="16" />

	<style name="buttonstyle"
		url="%SWFPATH%/plugins/textfield.swf" children="false"
		width="120" height="22"
		css="p{color:#000000; font-family:Arial; font-weight:bold; font-size:14; margin-left:5; margin-right:5; text-align:center; }" 
		backgroundcolor="0xFFFFFF" roundedge="5" shadow="1" borderwidth="0" glow="4" glowcolor="0xFFFFFF" 
		visible="false" 
		onover="tween(alpha,0.7,distance(0.3,0.2));" 
		onout="tween(alpha,1.0,distance(0.3,0.2));" 
		onloaded="set(alpha,0);set(textblur,15);set(blur,15); set(visible,true); tween(alpha,1,0.3); tween(textblur,0,0.3); tween(blur,0,0.3);"
		/>

	<plugin name="p1" keep="true" style="buttonstyle"
		html="[p]click me[/p]"
		align="bottom" x="0" y="75"
		onclick="tween(x,0)"
		/>

	<plugin name="left" keep="true" style="buttonstyle" width="30"
		html="[p]left[/p]"
		align="bottom" x="-70" y="25"
		onclick="move_by(p1,dec,100,-315);"
		/>

	<plugin name="right" keep="true" style="buttonstyle" width="30"
		html="[p]right[/p]"
		align="bottom" x="70" y="25"
		onclick="move_x_by(p1,inc,100,315);"
		/>

	<action name="move_x_by">
		copy(temp,plugin[%1].x);
		%2(temp, %3,%4,%4);
		tween(plugin[%1].x, get(temp));
	</action>

</krpano>


the action move_x_by(arg1,arg2,arg3,arg4); needs:
arg1 = name of the plugin to be moved
arg2 = inc or dec (increase/decrease)
arg3 = value to increase/decrease by
arg4 = max and min value for the inc or dec ( inc(var,byvalue*,max*,min*) )

Hope this help...

SAlut.

19

Sunday, October 3rd 2010, 6:24am

Thank you Michel and others!!!

I'll be playing with the values on monday.
Thank you very much for your explanation and code!!

Best Regards!!

Daniel

20

Friday, October 8th 2010, 7:46am

Hi Guys,

I'm here to thank you for the code sample and all instructions!!

Hope one day to be able to help you guys too!

THanks a lot!
Daniel