You are not logged in.

bulp

Intermediate

  • "bulp" started this thread

Posts: 390

Location: Malaysia

  • Send private message

1

Friday, June 28th 2013, 3:26pm

limit dragable layer within the screen / canvas area

id notice this script an xml example of dragablelayer totally can drag out of screen / canvas area..

anyway how to limit it with in canvas / screen

thanks

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
	<action name="draglayer">
		if(%1 != dragging,
			copy(drag_currentx, x);
			copy(drag_currenty, y);
			copy(drag_stagex, mouse.stagex);
			copy(drag_stagey, mouse.stagey);
			set(drag_sx, +1);
			set(drag_sy, +1);
			if(align == righttop,    set(drag_sx,-1); );
			if(align == right,       set(drag_sx,-1); );
			if(align == rightbottom, set(drag_sx,-1); set(drag_sy,-1); );
			if(align == bottom,      set(drag_sy,-1); );
			if(align == leftbottom,  set(drag_sy,-1); );
			draglayer(dragging);
		  ,
			if(pressed,
				sub(dx, mouse.stagex, drag_stagex);
				sub(dy, mouse.stagey, drag_stagey);
				mul(dx, drag_sx);
				mul(dy, drag_sy);
				add(x, drag_currentx, dx);
				add(y, drag_currenty, dy);
				delayedcall(0, draglayer(dragging) );
			  );
		  );
	</action>

2

Tuesday, July 2nd 2013, 1:40pm

Hi,

that might be possible, but some work...

after these calls:
add(x, drag_currentx, dx);
add(y, drag_currenty, dy);

you would need to:
- check if the correct x/y coordinates plus the current element size (pixelwidth,pixelheight) is within the screen (stagewidth,stageheight)
- therefore it would be also necessary to check the 'edge' setting of the element and also add the ox/oy settings

Best regards,
Klaus