# Duplicating movieClips at runtime

**URL:** <https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043>\
**Category:** Uncategorized\
**Created:** [April 10, 2006, 2:48pm UTC](https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043 "2006-04-10T14:48:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![plumpnation](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/plumpnation/32/1929_2.png) [@plumpnation](https://forum.kirupa.com/u/plumpnation)\
**Post date:** [April 10, 2006, 2:48pm UTC](https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043/1 "2006-04-10T14:48:00Z")

</div>

I’m in a bit of a pickle and was wondering if anyone out there could help.

function RotateDisplayOrDrag(whichPiece) {  
if (Key.isDown(18)) {  
\_root[whichPiece].\_rotation += 22.5;  
}  
if (Key.isDown(17)) {  
\_root[whichPiece].\_rotation -= 22.5;  
}

if (Key.isDown(68)) {  
\_root[whichPiece].duplicateMovieClip(“chair” + x, 5);

} else {  
startDrag(\_root[whichPiece]);  
}  
}  
For all those who recognize parts of this script, its robbed from mx’s puzzle tutorial.  
I’m taking parts of it to make an office furniture planning tool.

I just need the movieClip to be duplicated when I hold the letter ‘d’ (Ascii = 68). When I use the above script, it duplicates once, but removes the last duplicate when I use again.

Any help will be appreciated, but if not, hey, good luck with your flash developing, cos it’s seriously worthwhile. What a programme!!!

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [April 10, 2006, 3:06pm UTC](https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043/2 "2006-04-10T15:06:43Z")

</div>

> [@plumpnation](#):
>
> I’m in a bit of a pickle and was wondering if anyone out there could help.
> 
> function RotateDisplayOrDrag(whichPiece) {  
> if (Key.isDown(18)) {  
> \_root[whichPiece].\_rotation += 22.5;  
> }  
> if (Key.isDown(17)) {  
> \_root[whichPiece].\_rotation -= 22.5;  
> }
> 
> if (Key.isDown(68)) {  
> \_root[whichPiece].duplicateMovieClip(“chair” + x, 5);
> 
> } else {  
> startDrag(\_root[whichPiece]);  
> }  
> }  
> For all those who recognize parts of this script, its robbed from mx’s puzzle tutorial.  
> I’m taking parts of it to make an office furniture planning tool.
> 
> I just need the movieClip to be duplicated when I hold the letter ‘d’ (Ascii = 68). When I use the above script, it duplicates once, but removes the last duplicate when I use again.
> 
> Any help will be appreciated, but if not, hey, good luck with your flash developing, cos it’s seriously worthwhile. What a programme!!!

you need to put each duplicate at a different depth, try this

```auto
var i=1
function RotateDisplayOrDrag(whichPiece) {
if (Key.isDown(18)) {
_root[whichPiece]._rotation += 22.5;
} 
if (Key.isDown(17)) {
_root[whichPiece]._rotation -= 22.5;
}

if (Key.isDown(68)) {
_root[whichPiece].chair.duplicateMovieClip("chair"+i,i)
i++

} else {
startDrag(_root[whichPiece]);
}
}

```

---

<div class="post-metadata">

**Author:** ![plumpnation](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/plumpnation/32/1929_2.png) [@plumpnation](https://forum.kirupa.com/u/plumpnation)\
**Post date:** [April 13, 2006, 10:45am UTC](https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043/3 "2006-04-13T10:45:30Z")

</div>

hey man sorry about the delayed thanks, I’m having to spread myself a bit thin here. Now I have Php and MySQL to contend with…  
Enough of me, I really appreciate the time it took to read and reply to my problem. Now that I look at your reply, I realise just how simple it can be if you just sit back and think about it.

Again, a big ol heap of thanks…

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [April 16, 2006, 6:53pm UTC](https://forum.kirupa.com/t/duplicating-movieclips-at-runtime/185043/4 "2006-04-16T18:53:49Z")

</div>

> [@plumpnation](#):
>
> hey man sorry about the delayed thanks, I’m having to spread myself a bit thin here. Now I have Php and MySQL to contend with…  
> Enough of me, I really appreciate the time it took to read and reply to my problem. Now that I look at your reply, I realise just how simple it can be if you just sit back and think about it.
> 
> Again, a big ol heap of thanks…

welcome
