# Constraining a draggable object

**URL:** <https://forum.kirupa.com/t/constraining-a-draggable-object/233964>\
**Category:** Uncategorized\
**Created:** [July 28, 2007, 8:41pm UTC](https://forum.kirupa.com/t/constraining-a-draggable-object/233964 "2007-07-28T20:41:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![shellbryson](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@shellbryson](https://forum.kirupa.com/u/shellbryson)\
**Post date:** [July 28, 2007, 8:41pm UTC](https://forum.kirupa.com/t/constraining-a-draggable-object/233964/1 "2007-07-28T20:41:13Z")

</div>

Hi there,

I’ve been trying to figure out how to constrain an object in AS3. I know I’m supposed to use a rectangle object, but I cannot figure out the syntax. Can anyone post a quick sample? I want to only allow the panel below slide up and down, and only by Y number of pixels.

```auto

function makeControlPanel() {
addChild(controlP);
controlP.controlPanel_btn.addEventListener(MouseEvent.MOUSE_DOWN,controlPanelDrag);
controlP.controlPanel_btn.addEventListener(MouseEvent.MOUSE_UP,controlPanelStopDrag);
}

```
