Juduth
April 7, 2006, 2:03pm
1
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.
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
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");
}
}
wow… that is a wacky loop, lets fix that up first:
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.
Juduth
April 7, 2006, 2:22pm
3
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?
That will dupe it in the same posistion. Try this maybe:
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");
}
}
Juduth
April 7, 2006, 2:35pm
5
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
Ok, that makes it much clearer. As long as you have already built that array out of your XML
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");
}
}
Juduth
April 7, 2006, 2:46pm
7
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
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");
Juduth
April 7, 2006, 3:09pm
8
trace(dupedclip);
trace(this.miembro);
Output:
undefined
undefined
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.
Juduth
April 7, 2006, 3:28pm
10
_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
Juduth
April 7, 2006, 3:43pm
11
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
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?