# Dragging

**URL:** https://forum.kirupa.com/t/dragging/1081
**Category:** flash
**Created:** [August 8, 2002, 2:28am UTC](https://forum.kirupa.com/t/dragging/1081 "2002-08-08T02:28:13Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![natalia](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@natalia](https://forum.kirupa.com/u/natalia)
#### Post date: [August 8, 2002, 2:28am UTC](https://forum.kirupa.com/t/dragging/1081/1 "2002-08-08T02:28:13Z")

</div>

Hey, i’m trying to get a box to drag (it’s a button within a movieclip), but my code just ends up dragging the whole stage, and i don’t know what i’m doing wrong. :-\

The code is:

on (press) {  
startDrag ("");  
}  
on (release) {  
stopDrag ();  
}

I tried putting the name of the button instance in the “”, but that just makes the code do nothing.

:q: :cyclops: :q:

---

<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: [August 8, 2002, 1:24pm UTC](https://forum.kirupa.com/t/dragging/1081/2 "2002-08-08T13:24:01Z")

</div>

Hi there,

i don’t understand what you mean by dragging the whole stage but I will explain how to get the object to drag.

Firstly you can drag only a movieclip so if u want to drag a button, create a button, then create a movieclip and from the library  
(Ctrl + L) drag the button onto the movieclip. then go to the main movie time line and drag the movie clip from the library onto the stage and give it an instance name in the instance dialogue box. then right click on the mc and click on the edit. then right click on the button and click on actions and give the following actions  
on (press) {  
startDrag ("/instance name of the movieclip");  
}  
on (release) {  
stopDrag ();  
}

This should 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: [August 8, 2002, 1:29pm UTC](https://forum.kirupa.com/t/dragging/1081/3 "2002-08-08T13:29:24Z")

</div>

Try startDrag(this);

pom :asian:

---

<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: [August 8, 2002, 4:20pm UTC](https://forum.kirupa.com/t/dragging/1081/4 "2002-08-08T16:20:28Z")

</div>

You need to specify what you want to drag. So…

on (press) {  
startDrag ("");  
}  
on (release) {  
stopDrag ();  
}

\<b\>should become\</b\>

on (press) {  
startDrag (“yourMC”);  
}  
on (release) {  
stopDrag ();  
}

where yourMC = the movie clip you want to be dragged.

---

<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: [August 8, 2002, 8:32pm UTC](https://forum.kirupa.com/t/dragging/1081/5 "2002-08-08T20:32:41Z")

</div>

hey,  
i tried converting the thing to a movieclip, and output says this:

Symbol=news, Layer=dragger, Frame=1: Line 1: Mouse events are permitted only for button instances  
on (press) {

Symbol=news, Layer=dragger, Frame=1: Line 4: Mouse events are permitted only for button instances  
on (release) {

So i converted it to a button again, and left “” blank, and it ends up dragging everything. What i mean about the ‘whole stage’ is that i have the button on top of a graphic (the bg), and it drags the background as well as the thing it’s supposed to be dragging.

Here’s the code i put on the button, with the button instance named:

on (press) {  
startDrag (“dragger”);  
}  
on (release) {  
stopDrag ();  
}

…dragger being the button instance. I tried that before i posted for the first time, nothing’s working… ☹ Basically, the only way i get _anything_ to drag, is if i have it as a button, and leave “” blank. ☹

---

<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: [August 8, 2002, 9:14pm UTC](https://forum.kirupa.com/t/dragging/1081/6 "2002-08-08T21:14:44Z")

</div>

If you want to drag the button, just type the instance name of your button between " "

---

<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: [August 8, 2002, 9:25pm UTC](https://forum.kirupa.com/t/dragging/1081/7 "2002-08-08T21:25:57Z")

</div>

There are no instance names for buttons in Flash 5, lost 😛  
Did you try startDrag (this) ?

pom :asian:

---

<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: [August 8, 2002, 9:33pm UTC](https://forum.kirupa.com/t/dragging/1081/8 "2002-08-08T21:33:29Z")

</div>

yea, i tried ‘this’, it doesn’t do anything…

I meant by instance name, i named the button ‘dragger’, then i put it on the stage, so that would be an instance of ‘dragger’.

---

<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: [August 8, 2002, 9:35pm UTC](https://forum.kirupa.com/t/dragging/1081/9 "2002-08-08T21:35:25Z")

</div>

lostinbeta, i’ve tried to explain that i did type in the name of the button between “”, but nothing will drag. ☹

---

<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: [August 8, 2002, 9:37pm UTC](https://forum.kirupa.com/t/dragging/1081/10 "2002-08-08T21:37:26Z")

</div>

Well I created a button named dragger. Then in the instance name I typed “dragger” (without quotes). Then I applied the exact code you added…

```auto

on (press) {
startDrag ("dragger");
}
on (release) {
stopDrag ();
}

```

Everything worked great. I even added more things into the movie just to see if everything would drag, nope, just the button was being drug around.

---

<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: [August 8, 2002, 9:39pm UTC](https://forum.kirupa.com/t/dragging/1081/11 "2002-08-08T21:39:15Z")

</div>

I would post the .fla, but it is Flash MX, so Flash 5 won’t be able to read it. If you use MX, let me know, I will post the .fla here for you in a .zip file.

---

<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: [August 8, 2002, 9:41pm UTC](https://forum.kirupa.com/t/dragging/1081/12 "2002-08-08T21:41:58Z")

</div>

There are no instance names for buttons!! (Haven’t I said that already?:P)  
If you want to drag anything, you have to target a movie clip. In this case, ‘this’. It works, I’ve just tested it (if you a button inside a movie clip, of course).

pom :asian:

---

<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: [August 8, 2002, 9:47pm UTC](https://forum.kirupa.com/t/dragging/1081/13 "2002-08-08T21:47:23Z")

</div>

There are instance names for buttons. I just tried it and it worked. I used it with buttons all the time.

Attached is a picture of the buton properties in Flash MX.

If there isn’t in Flash 5, sorry, I never learned deeply about Flash 5, I just figured they wouldn’t have changed that.

My apologies.

---

<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: [August 8, 2002, 9:53pm UTC](https://forum.kirupa.com/t/dragging/1081/14 "2002-08-08T21:53:01Z")

</div>

mmm

---

<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: [August 8, 2002, 9:53pm UTC](https://forum.kirupa.com/t/dragging/1081/15 "2002-08-08T21:53:13Z")

</div>

yea, i use flash 5, and there aren’t any instance names for buttons… grrr… i guess it only works on MX?! sigh.

the reason why lostinbeta’s solution doesn’t work in flash 5 is cuz there aren’t any instance names for buttons.

I’ll try pom’s idea now. 😛

---

<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: [August 8, 2002, 9:54pm UTC](https://forum.kirupa.com/t/dragging/1081/16 "2002-08-08T21:54:59Z")

</div>

No nee to apologize 🙂 Actually, instance names for buttons are new, and totally useless now that you can give movie clips button handlers…

pom :asian:

---

<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: [August 8, 2002, 9:58pm UTC](https://forum.kirupa.com/t/dragging/1081/17 "2002-08-08T21:58:56Z")

</div>

> \*Originally posted by natalia \*  
> \*\*hey,  
> i tried converting the thing to a movieclip, and output says this:

Symbol=news, Layer=dragger, Frame=1: Line 1: Mouse events are permitted only for button instances  
on (press) {

Symbol=news, Layer=dragger, Frame=1: Line 4: Mouse events are permitted only for button instances  
on (release) {

So i converted it to a button again, and left “” blank, and it ends up dragging everything. \*\*  
OK, there is the problem. Let take this back from the beginning:  
You have a graphic, you turn it into a button, and give it the code

```auto
on (press) {startDrag (this);}

```

For the moment, this refers to the \_root (the parent of the button) so it won’t work.  
Now turn your button into a movie clip (F8) and that’s it! 🙂

pom :asian:

---

<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: [August 8, 2002, 9:59pm UTC](https://forum.kirupa.com/t/dragging/1081/18 "2002-08-08T21:59:59Z")

</div>

okay, now i’m hopelessly confused. all i wanted to do was to make this little box drag…

i can’t do button instances on flash 5.  
if i make it into a movieclip, i can’t use the ‘on’ code in the actionscript box because i need an ‘onclip’ code. With the ‘onclip’, it doesn’t drag.

---

<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: [August 8, 2002, 10:00pm UTC](https://forum.kirupa.com/t/dragging/1081/19 "2002-08-08T22:00:59Z")

</div>

k pom, i posted the above right after you posted the new solution… i’ll try that =)

---

<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: [August 9, 2002, 5:07pm UTC](https://forum.kirupa.com/t/dragging/1081/20 "2002-08-09T17:07:54Z")

</div>

see attachment.🙂
