# Duplicate movieclip help

**URL:** <https://forum.kirupa.com/t/duplicate-movieclip-help/184756>\
**Category:** flash\
**Created:** [April 7, 2006, 2:03pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756 "2006-04-07T14:03:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 2:03pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/1 "2006-04-07T14:03:36Z")

</div>

I have a movieclip with text linked to an Xml and I need a function to duplicate that movieClip. I need a number of clips equal to the Xml’s tags (but I have that function done, so nevermind)

I need the part of the function wich changes the default movieclip in order to load de next Xml node too.

This is the part of the code wich loads Xml node values to dynamic text objects.

```auto
avatar.loadMovie(image[0], 1);
        nom.text = nombre[0];
        pers.text = personajes[0];
        nomPers.text = nombrePersonaje[0];
        nomPers2.text = nombrePersonaje2[0];
        razaPers.text = raza[0];
        jobsPers.text = jobs[0];

```

Those zeros must change when the moviclip is duplicated

This is a code I’ve done, but I know I’m missing something. I’t doesn’t works at all 😃

```auto
function duplicarClips() {
    function loadXML(loaded) {
        if (loaded) {
            this.cargado.text = "Cargado!";
            xmlNode = this.firstChild;
            total = xmlNode.childNodes.length;
            amount = total;
            while (amount>0) {
                duplicateMovieClip(this.miembro, "miembro"+1, i);
                i = i+1;
                amount = amount-1;
            }
        }
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        xmlData.load("miembros.xml");
    }
}

```

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 7, 2006, 2:07pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/2 "2006-04-07T14:07:48Z")

</div>

wow… that is a wacky loop, lets fix that up first:

```auto
function duplicarClips() {
    function loadXML(loaded) {
        if (loaded) {
            this.cargado.text = "Cargado!";
            xmlNode = this.firstChild;
            total = xmlNode.childNodes.length;
            var i:Number = 0;
            while (i<=total) {
                duplicateMovieClip(this.miembro, "miembro"+i, i);
                i++;
            }
        }
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        xmlData.load("miembros.xml");
    }
}

```

For the record, I’m not really sure what you are trying to accomplish here. The description of your issue and the code don’t seem to line up.

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 2:22pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/3 "2006-04-07T14:22:05Z")

</div>

Yeah! That wasn’t good at all! But it stills not to dupicate the clip! Or may it be dupicating it at the same position?

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 7, 2006, 2:25pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/4 "2006-04-07T14:25:02Z")

</div>

That will dupe it in the same posistion. Try this maybe:

```auto
function duplicarClips() {
    function loadXML(loaded) {
        if (loaded) {
            this.cargado.text = "Cargado!";
            xmlNode = this.firstChild;
            total = xmlNode.childNodes.length;
            var i:Number = 0;
            while (i<=total) {
                var dupedclip:MovieClip = duplicateMovieClip(this.miembro, "miembro"+i, i);
                dupedclip._x = 10*i
                dupedclip._y = 100
                i++;
            }
        }
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        xmlData.load("miembros.xml");
    }
}

```

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 2:35pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/5 "2006-04-07T14:35:44Z")

</div>

What I need is a function that duplicates the movieclip miembro x times (where x is the number of members on an xml I load) and that shows each member xml node values in order.

I have a gimp representation 😃

[http://img467.imageshack.us/my.php?image=xd7ol.png](http://img467.imageshack.us/my.php?image=xd7ol.png)

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 7, 2006, 2:41pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/6 "2006-04-07T14:41:42Z")

</div>

Ok, that makes it much clearer. As long as you have already built that array out of your XML

```auto
function duplicarClips() {
    function loadXML(loaded) {
        if (loaded) {
            this.cargado.text = "Cargado!";
            xmlNode = this.firstChild;
            total = xmlNode.childNodes.length;
            var i:Number = 0;
            while (i<=total) {
                var dupedclip:MovieClip = duplicateMovieClip(this.miembro, "miembro"+i, i);
                dupedclip._x = 10*i
                dupedclip._y = 100
                dupedclip.avatar.loadMovie(image*, 1);
                dupedclip.nom.text = nombre*;
                dupedclip.pers.text = personajes*;
                dupedclip.nomPers.text = nombrePersonaje*;
                dupedclip.nomPers2.text = nombrePersonaje2*;
                dupedclip.razaPers.text = raza*;
                dupedclip.jobsPers.text = jobs*;
                i++;
            }
        }
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        xmlData.load("miembros.xml");
    }
}

```

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 2:46pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/7 "2006-04-07T14:46:26Z")

</div>

In theory that’s Ok but it doesn´t work

Here is my entire as which is inside the miembro movieclip. Have it a look pliz

```auto
function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        nombre = [];
        personajes = [];
        nombrePersonaje = [];
        nombrePersonaje2 = [];
        raza = [];
        jobs = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            nombre* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            personajes* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            nombrePersonaje* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
            nombrePersonaje2* = xmlNode.childNodes*.childNodes[3].attributes["dos"];
            raza* = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
            jobs* = xmlNode.childNodes*.childNodes[5].firstChild.nodeValue;
        }
        
        this._parent.cargado.text = "Cargado!";
        var i:Number = 0;
        while (i<=total) {
            var dupedclip:MovieClip = duplicateMovieClip(this.miembro, "miembro"+i, i);
            dupedclip._x = 10*i;
            dupedclip._y = 100;
            dupedclip.avatar.loadMovie(image*, 1);
            dupedclip.nom.text = nombre*;
            dupedclip.pers.text = personajes*;
            dupedclip.nomPers.text = nombrePersonaje*;
            dupedclip.nomPers2.text = nombrePersonaje2*;
            dupedclip.razaPers.text = raza*;
            dupedclip.jobsPers.text = jobs*;
            i++;
        }
        
    } else {
        content = "Fichero no cargado!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("miembros.xml");

```

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 3:09pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/8 "2006-04-07T15:09:51Z")

</div>

trace(dupedclip);  
trace(this.miembro);

Output:  
undefined  
undefined

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 7, 2006, 3:13pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/9 "2006-04-07T15:13:19Z")

</div>

this.miembro is your problem, try playing with the targetting on this.

If this.miembro doesn’t exist, the variable you make when duplicating will not exist either.

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 3:28pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/10 "2006-04-07T15:28:14Z")

</div>

\_root.miembro is the correct taget! But it seems to make an infinite loop in the same position because Flash hangs!  
I think it is because I need to duplicate the clip out of the miembro movieclip

Thanks for all! I will continue trying 😃

---

<div class="post-metadata">

**Author:** ![Juduth](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/juduth/32/2335_2.png) [@Juduth](https://forum.kirupa.com/u/Juduth)\
**Post date:** [April 7, 2006, 3:43pm UTC](https://forum.kirupa.com/t/duplicate-movieclip-help/184756/11 "2006-04-07T15:43:04Z")

</div>

I’ve put the as out of the movieCLip and the infinite loop disapears. But I still don’t know how not to dupilcate in the same place.

This was your code

```auto
dupedclip._x = 10*i;
dupedclip._y = 100;

```

It dupliates in the same place because the clip always duplicated is miembros one (wich is always in position x=0 y=0)

Some advices?
