# \[FMX\]Duplicating then attaching

**URL:** <https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553>\
**Category:** flash\
**Created:** [January 19, 2003, 12:33am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553 "2003-01-19T00:33:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Staticreator](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Staticreator](https://forum.kirupa.com/u/Staticreator)\
**Post date:** [January 19, 2003, 12:33am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/1 "2003-01-19T00:33:59Z")

</div>

I have a program that has an extensive library, it uses the attachMovie function to often put one-frame movies on the screen. However, in one case I need more than one instance of something in the library so I thought the following code would work fine. Oh, and it’s copying the movie “pellet”

```php
var newMovieName = "pellet_"+newPos
pellet.duplicateMovieClip(newMovieName,1)
_root.attachMovie(_root[newMovieName],newMovieName,1)

```

It just simply won’t work…no matter what I try, can I get some 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:** [January 19, 2003, 12:53am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/2 "2003-01-19T00:53:07Z")

</div>

its because you are using the same depth over again, use a different number or better yet a variable that gets 1 added to it everytime you use it

```php

var newMovieName = "pellet_"+newPos
pellet.duplicateMovieClip(newMovieName,depth++)
_root.attachMovie(_root[newMovieName],newMovieName,depth++)

```

---

<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:** [January 19, 2003, 2:00am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/3 "2003-01-19T02:00:13Z")

</div>

:-\ sorry…it didn’t help…could there be any other problems?

---

<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:** [January 19, 2003, 5:33am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/4 "2003-01-19T05:33:06Z")

</div>

LOL… I am going to take a wild shot in the dark and probably shoot my foot, but does this help?

```php
var newMovieName = _root["pellet_"+newPos]
pellet.duplicateMovieClip(newMovieName,depth++)
newMovieName.attachMovie(newMovieName,depth++)

```

---

<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:** [January 19, 2003, 5:41am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/5 "2003-01-19T05:41:21Z")

</div>

…they also have the same instance name which isnt exactly good (my first post was a quicky heh)… attachMovie is also missing a parameter

---

<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:** [January 19, 2003, 5:45am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/6 "2003-01-19T05:45:59Z")

</div>

I usually test code I put out before I post it, but I don’t have flash open and my comp is all crazy like, so I figured I would just give it a shot without testing. I always get it wrong when I do that…lol. I have no clue why. I could type it out fine in Flash (always in advanced mode), but when I type it out in the forum I mess something up. Hmmm, oh well 😉

---

<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:** [January 19, 2003, 5:59am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/7 "2003-01-19T05:59:32Z")

</div>

yeah its a lot faster and easier to throw up a “possibly correct” answer 😉 and if it doesnt work, look at it a little better and give a better one… if it keeps not working then test it heh. Sometimes I dont even ready the question fully (I get a lot of mis-answers doing that though lol)

---

<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:** [January 19, 2003, 5:59am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/8 "2003-01-19T05:59:55Z")

</div>

lostinbeta:

I have tried several times to check your site because you seem to have a bead on what your doing.  
I see you have it masked to a sub dir at 8ball.  
But the redirect is increadably slow and 404’s all the time.  
Just wanted you ta know…

---

<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:** [January 19, 2003, 6:05am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/9 "2003-01-19T06:05:23Z")

</div>

Sen: Yes, same here. I tend to not read fully, or skim fast and miss an important word and end up doing the wrong thing.

rynoe: My server is down. Tech-Support said it was hard drive failure (luckily the backup was done the day before it went down) and they are replacing the hard drive now. They stated that it should be up and running by tomorrow. Notice the footer is not loading as well… same reason.

---

<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:** [January 19, 2003, 6:09am UTC](https://forum.kirupa.com/t/fmx-duplicating-then-attaching/11553/10 "2003-01-19T06:09:25Z")

</div>

I see…
