PDA

View Full Version : Duplicate movie blip for menu.



_this
March 13th, 2006, 09:15 AM
i creat one movie clip that ll be load dinamic text and image from one xml document. well... i wanna do this with duplicateMovieClip but no work.



path = "";
//#
var xmlMenu:XML = new XML();
xmlMenu.ignoreWhite = true;
xmlMenu.load('data.xml');
xmlMenu.onLoad = function() {
qtd = this.childNodes[0].childNodes.length;
for (i=0; i<qtd; i++) {
var nome = (this.childNodes[0].childNodes[i].childNodes[0]);
var imagemp = (this.childNodes[0].childNodes[i].childNodes[1]);
var imagemg = (this.childNodes[0].childNodes[i].childNodes[2]);
//#
duplicateMovieClip (but, "but"+i, i);
setProperty("but"+i, _x, ((i+1)*23));
setProperty("but"+i, _y, 23);
//#

//#
"but"+i.imagem.loadMovie(path + "small/" + imagemp);
"but"+i.textofoto.htmlText = nome;
"but"+i.onRelease = function() { getURL(path + "large/" + imagemg); };
};
};
//#
this.stop();


:red: any idea ? please help-me.

KyoKusanagi
March 13th, 2006, 09:48 AM
path = "";
//#
var xmlMenu:XML = new XML();
xmlMenu.ignoreWhite = true;
xmlMenu.onLoad = function(success) {
if(success){
qtd = parseInt(this.childNodes[0].childNodes.attribute.length);
for (i=0; i<qtd; i++) {
var nome = (this.childNodes[0].childNodes[i].childNodes[0].nodeValue);
var imagemp = (this.childNodes[0].childNodes[i].childNodes[1].nodeValue);
var imagemg = (this.childNodes[0].childNodes[i].childNodes[2].nodeValue);
//#
duplicateMovieClip (but, "but"+i, i);
setProperty(eval("but"+i,) _x, ((i+1)*23));
setProperty(eval("but"+i), _y, 23);
//#

//#
eval("but"+i".imagem.loadMovie(path + "small/" + imagemp)");
eval("but"+i".textofoto.htmlText = nome");
eval("but"+i".onRelease = function() { getURL(path + "large/" + imagemg)"; };
};
};
xmlMenu.load('data.xml');
//#
this.stop();
Just added some things that you might had forget.

Please do mind to post your XML so we would know your structure.

scotty
March 13th, 2006, 09:56 AM
You don't need all 'eval' s

var xmlMenu:XML = new XML();
xmlMenu.ignoreWhite = true;
xmlMenu.load('data.xml');
xmlMenu.onLoad = function() {
qtd = this.childNodes[0].childNodes.length;
for (i=0; i<qtd; i++) {
var btn = but.duplicateMovieClip("but"+i, i);
btn.nome = this.childNodes[0].childNodes[i].childNodes[0];
btn.imagemp = this.childNodes[0].childNodes[i].childNodes[1];
btn.imagemg = this.childNodes[0].childNodes[i].childNodes[2];
btn._x = (i+1)*23;
btn._y = 23;
btn.imagem.loadMovie(path+"small/"+btn.imagemp);
btn.textofoto.htmlText = btn.nome;
btn.onRelease = function() {
getURL(path+"large/"+this.imagemg);
};
}
};

Like KyoKusanagi, I'm not sure about the xml structure as well;)

scotty(-:

_this
March 13th, 2006, 09:58 AM
see this.. my fla and xml.
and thanks in advance for help
:D

scotty
March 13th, 2006, 10:32 AM
stop();
var xmlMenu:XML = new XML();
xmlMenu.ignoreWhite = true;
xmlMenu.load('data.xml');
xmlMenu.onLoad = function() {
qtd = this.childNodes[0].childNodes.length;
for (i=0; i<qtd; i++) {
var btn = but.duplicateMovieClip("but"+i, i);
btn.nome = this.childNodes[0].childNodes[i].childNodes[0].firstChild.nodeValue;
btn.imagemp = this.childNodes[0].childNodes[i].childNodes[1].firstChild.nodeValue;
btn.imagemg = this.childNodes[0].childNodes[i].childNodes[2].firstChild.nodeValue;
btn._x = (i+1)*23;
btn._y = 23;
btn.imagem.loadMovie(path+"small/"+btn.imagemp);
btn.texto.textofoto = btn.nome;
btn.onRelease = function() {
getURL(path+"large/"+this.imagemg);
};
}
};

scotty(-:

_this
March 13th, 2006, 10:44 AM
Great work and many thanks scotty and KyoKusanagi.
:D:D:D:D

scotty
March 13th, 2006, 11:20 AM
no problem =)