# Urgent help needed: Restricting object(movie Clip) in a defined boundry

**URL:** <https://forum.kirupa.com/t/urgent-help-needed-restricting-object-movie-clip-in-a-defined-boundry/308671>\
**Category:** flash\
**Created:** [April 28, 2010, 2:49am UTC](https://forum.kirupa.com/t/urgent-help-needed-restricting-object-movie-clip-in-a-defined-boundry/308671 "2010-04-28T02:49:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leeda111](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@leeda111](https://forum.kirupa.com/u/leeda111)\
**Post date:** [April 28, 2010, 2:49am UTC](https://forum.kirupa.com/t/urgent-help-needed-restricting-object-movie-clip-in-a-defined-boundry/308671/1 "2010-04-28T02:49:10Z")

</div>

Hi,

I am new to flash. I am trying to create a game right now. Soewhat same at the game “This is the only level”([http://armorgames.com/play/4309/this-is-the-only-level](http://armorgames.com/play/4309/this-is-the-only-level))

I want to restrict the cartoon(movie object) within this boundary which I have created using line tool(I can even create rectangles if needed).

![](http://shup.com/Shup/324829/47700067.png)

Here is the code so far

```auto
var mycartoon:cartoon = new cartoon();
mycartoon.x=stage.stageWidth/2;
mycartoon.y=stage.stageHeight/2;
addChild(mycartoon);
mycartoon.name="mycartoon";
mycartoon.x = 200;
mycartoon.y = 100;

mycartoon.addEventListener(MouseEvent.MOUSE_OUT, rotatecartoon);
function rotatecartoon(event:Event):void {
	
	
	var rad:Number=Math.atan2(mouseY-mycartoon.y,mouseX-mycartoon.x);
	

	var p1:Point=new Point(mouseX,mouseY);
	var p2:Point=new Point(mycartoon.x,mycartoon.y);
	var distance:Number=Point.distance(p1,p2);

	var polar:Point=Point.polar(distance,rad);
	mycartoon.x+=polar.x;
	mycartoon.y+=polar.y;

}

```

Any advice will be really appreciated. Thanks in advance

edit: I cant use startdrag as I will be using keyboard controls as well to move the cartoon
