# Preventing movie clip moving off frame

**URL:** <https://forum.kirupa.com/t/preventing-movie-clip-moving-off-frame/70293>\
**Category:** flash\
**Created:** [November 12, 2004, 8:27am UTC](https://forum.kirupa.com/t/preventing-movie-clip-moving-off-frame/70293 "2004-11-12T08:27:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stockdill](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@stockdill](https://forum.kirupa.com/u/stockdill)\
**Post date:** [November 12, 2004, 8:27am UTC](https://forum.kirupa.com/t/preventing-movie-clip-moving-off-frame/70293/1 "2004-11-12T08:27:29Z")

</div>

Hi I have a movieclip called soldierriver. Is can be moved around the stage by using the cursor keys. What I want is to prevent him from be moved off the stage. I know with drag and drop you use  
startDrag(this,true,0,0,500,400);

But I don’t know how to add this into the code I am using for the cursor keys which is as follows.

onClipEvent(enterFrame) {  
if (Key.isDown(Key.RIGHT)) {  
\_root.soldierriver.\_x++;  
}

```
if (Key.isDown(Key.LEFT)) {
	_root.soldierriver._x--;
}

if (Key.isDown(Key.UP)) {
	_root.soldierriver._y--;
}

if (Key.isDown(Key.DOWN)) {
	_root.soldierriver._y++;
}

```

Can someone please tell me how to include it in my code?  
Cheers  
Lesley
