# Draggable duplicates

**URL:** <https://forum.kirupa.com/t/draggable-duplicates/56652>\
**Category:** Uncategorized\
**Created:** [July 6, 2004, 2:35pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652 "2004-07-06T14:35:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![guitarzen](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@guitarzen](https://forum.kirupa.com/u/guitarzen)\
**Post date:** [July 6, 2004, 2:35pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/1 "2004-07-06T14:35:41Z")

</div>

I am using the current coding to duplicate a symbol on the stage. I would like to be able to then grab them all and move around at once.

This is a huge hurdle I am trying to get over so any help will be appreciated.

on (release) {  
var amount = 6;  
for (var i = 1; i\<=amount; i++) {  
\_root.duplicateMovieClip (\_root.testy, “ball”+i, i);  
\_root[“ball”+i].\_y = (\_root[“ball”+(i-1)].\_y)+35; }  
}

---

<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:** [July 6, 2004, 2:58pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/2 "2004-07-06T14:58:16Z")

</div>

You want to be able to grab any one but all of them move together? Then create another movie clip, say called “dragger” and put your duplicate code inside of it (instead of on \_root). Then use the drag code on dragger.

:hr:

---

<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:** [July 6, 2004, 3:24pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/3 "2004-07-06T15:24:38Z")

</div>

Unfortunaltey I think i’m going to need this one spelled out to me because I cannot get it to work. I will explain in more detail what I want.

On my main screen I have a button. When it is pressed I want it to duplicate into a row and then be able to drag all those around at once. So when i press that button for duplicates…how do i trigger it in another movie? Keep in mind I want to do this for a lot of buttons so if I can make it universal for them to load into the same MC and just replace the existing buttons…it would help out.

I apologize for being new to this but I’m so close to a final project and this is a huge hang up. I am using MX.

---

<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:** [July 6, 2004, 3:40pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/4 "2004-07-06T15:40:36Z")

</div>

Don’t ever apologize for being new, we were all new once and we are all still learning 🙂

Okay, thanks for expanding on your setup - that helps. I guess what I would do (and the beauty of flash is that there are always 12 ways to do something, and the beauty of the forums is that you can usually get more than one opinion) would be to create a movie clip and call it “menu” or something (are your buttons a menu system?). Put your button symbol inside of this movie clip. Then you can use the same code to duplicate the symbol but since you now have this going on inside a movie clip you want to include that movie clip in your path:

```auto

on (release) {
var amount = 6;
for (var i = 1; i<=amount; i++) {
_root.menu.duplicateMovieClip (_root.menu.testy, "ball"+i, i);
_root.menu["ball"+i]._y = (_root.menu["ball"+(i-1)]._y)+35; }
}

```

This is untested but should work. Since you are running this code from inside a movie clip you may even be able to substitute \_root.menu with this (the word this) as ‘this’ always refers to the timeline of the movieclip you are running the code from. At least that’s how I understand it to work! 😉

As for the dragging code just put that on the maintimeline and refer to the menu movieclip (since it contains all the buttons) or on the menu movie clip itself with some kind of event handler. You might have to play around with that a bit.

Hope this helps  
:hr:

---

<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:** [July 6, 2004, 3:55pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/5 "2004-07-06T15:55:38Z")

</div>

Oops, I had the code a bit off. I made this example for you so you could see what I mean by the setup.

Hope this is what you want!

:hr:

---

<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:** [July 6, 2004, 3:58pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/6 "2004-07-06T15:58:44Z")

</div>



---

<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:** [July 6, 2004, 4:01pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/7 "2004-07-06T16:01:32Z")

</div>

:h: 😉

---

<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:** [July 6, 2004, 4:12pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/8 "2004-07-06T16:12:14Z")

</div>

Wow, thanks a bunch! I was so close to it but my “testy” reference was in the wrong place.

One last thing I would like to do is be able to place it on the stage anywhere I chose when it duplicates…any ideas?

---

<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:** [July 6, 2004, 4:30pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/9 "2004-07-06T16:30:51Z")

</div>

I got it now…thanks again. Now for the grunt 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:** [July 6, 2004, 6:18pm UTC](https://forum.kirupa.com/t/draggable-duplicates/56652/10 "2004-07-06T18:18:08Z")

</div>

Glad you got it working :thumb:
