# Need help with setting boundaries for dragging my movie clip

**URL:** <https://forum.kirupa.com/t/need-help-with-setting-boundaries-for-dragging-my-movie-clip/291613>\
**Category:** flash\
**Created:** [July 2, 2009, 10:10am UTC](https://forum.kirupa.com/t/need-help-with-setting-boundaries-for-dragging-my-movie-clip/291613 "2009-07-02T10:10:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![juss](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@juss](https://forum.kirupa.com/u/juss)\
**Post date:** [July 2, 2009, 10:10am UTC](https://forum.kirupa.com/t/need-help-with-setting-boundaries-for-dragging-my-movie-clip/291613/1 "2009-07-02T10:10:32Z")

</div>

[SIZE=1]Hi there,[/SIZE]

[SIZE=1]I really need help with one of my project. [/SIZE]

[SIZE=1]I have created this swf that allows me to drag my movie clip around with easing effects. However, if I drag it too fast, my movie clip will actually goes out of my “flash”.[/SIZE]  
[SIZE=1](PS: I actually got this script from a user in this forum. Sorry about that. Hence, i left the credits there.)[/SIZE]  
[SIZE=1][/SIZE]

[SIZE=1]Is there anyway where I can set the boundaries where the movie clip can be dragged to? [/SIZE]  
[SIZE=1]I’ve came across a website where the effect of dragging within a specific area is exactly what I desired.[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1]Here’s the link to the website. [/SIZE][[SIZE=1]http://www.conceptm.nl/[/SIZE]](http://www.conceptm.nl/)

[SIZE=1]Also, I’m using AS2 and here it is.[/SIZE]  
[SIZE=1][/SIZE]  
[SIZE=1][/SIZE]

[SIZE=1][COLOR=blue]//Tutorial criado pela Cabana Criação: [/COLOR][/SIZE][[SIZE=1][COLOR=blue]www.cabanacriacao.com[/COLOR][/SIZE]](http://www.cabanacriacao.com)  
[SIZE=1][COLOR=blue]//Visite também o Cabanoblog: [/COLOR][/SIZE][[SIZE=1][COLOR=blue]www.cabanacriacao.com/blog[/COLOR][/SIZE]](http://www.cabanacriacao.com/blog)  
[SIZE=1][COLOR=blue]\_root.myMC.ease = 5;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_root.myMC.onPress = function() {[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]startDrag(this);[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.drag = false;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_global.myMCx1 = \_root.\_xmouse;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_global.myMCy1 = \_root.\_ymouse;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]/_trace("x1 = " + myMCx1);[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]trace("y1 = " + myMCy1);_/[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_root.myMC.onEnterFrame = function() {[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]//trace("funciona? = " + myMCx1);[/COLOR][/SIZE]

[SIZE=1][COLOR=blue]if (this.drag == true) {[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.\_x += (this.targX-this.\_x)/this.ease;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.\_y += (this.targY-this.\_y)/this.ease;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_root.myMC.onRelease = function() {[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.drag = true;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]stopDrag();[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_global.myMCx2 = \_root.\_xmouse;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_global.myMCy2 = \_root.\_ymouse;[/COLOR][/SIZE]

[SIZE=1][COLOR=blue]if((myMCx1-myMCx2)\<0){[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.targX = \_root.myMC.\_x+100; [/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]if((myMCx1-myMCx2)\>0){[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.targX = \_root.myMC.\_x-100; [/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]if((myMCy1-myMCy2)\<0){[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.targY = \_root.myMC.\_y+100; [/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]if((myMCy1-myMCy2)\>0){[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.targY = \_root.myMC.\_y-100; [/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]\_root.myMC.onReleaseOutside = function() {[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]this.drag = false;[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]stopDrag();[/COLOR][/SIZE]  
[SIZE=1][COLOR=blue]}[/COLOR][/SIZE]  
[SIZE=1][COLOR=#0000ff][/COLOR][/SIZE]

[SIZE=1][COLOR=black]Will be really grateful for the helps. Thanks in advance![/COLOR][/SIZE]
