# Drag only one button

**URL:** https://forum.kirupa.com/t/drag-only-one-button/5690
**Category:** Uncategorized
**Created:** [September 19, 2002, 3:55pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690 "2002-09-19T15:55:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![wa\_ha\_ha\_ha\_ha](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wa_ha_ha_ha_ha/32/55_2.png) [@wa\_ha\_ha\_ha\_ha](https://forum.kirupa.com/u/wa_ha_ha_ha_ha)
#### Post date: [September 19, 2002, 3:55pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/1 "2002-09-19T15:55:18Z")

</div>

Hi!  
what is the right action script to drag a particular button without draging others. If I put the action script that I wrote below, it will let me to drag everything, even my background.  
Thanks a lot!!!

–action script–

on (press) {  
this.startDrag()  
}  
on (release) {  
this.stopDrag()  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 4:02pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/2 "2002-09-19T16:02:08Z")

</div>

Try this…

on (press) {  
startDrag(this)  
}  
on (release) {  
stopDrag()  
}

PS: I am moving this thread to the Actionscript forum as this has nothing to do with HTML or Javascript and you posted it in the HTML/Javascript forum.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 4:15pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/3 "2002-09-19T16:15:45Z")

</div>

Thanks a lot! I will post in the right place next time!  
Thanks again!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 4:21pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/4 "2002-09-19T16:21:03Z")

</div>

No problem. Glad I could help:)

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 4:55pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/5 "2002-09-19T16:55:08Z")

</div>

I think you may find that the background is being dragged because the button is sitting on the main timeline (in which case this.startDrag() and startDrag(this) will both reference \_root).

I’d suggest you place the button inside an instance of a movie clip: select the instance of the button, press F8 and choose Movie Clip. Then either this.startDrag() and startDrag(this) will work.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 5:06pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/6 "2002-09-19T17:06:33Z")

</div>

Ah yes, you are completely right there. For some reason that thought never popped into my head.

Thanks for the correction jsk.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 19, 2002, 5:31pm UTC](https://forum.kirupa.com/t/drag-only-one-button/5690/7 "2002-09-19T17:31:13Z")

</div>

Absolutely right jsk. When you define an on (something) event, and if you use this, you refer to the clip containing the button (the \_root in this case).

In MX, there’s another way to solve this: declare a dynamic even handler in the timeline. For instance:

```auto
but.onPress=startDrag;

```

pom :asian:
