如何从XML复制MovieClip,相互之间,大小不同?

时间:2011-06-09 18:08:07

标签: actionscript actionscript-2

我有这个脚本,我想知道如何相互复制动画片段。这个脚本适用于宽度相同的图像,但是当尺寸不同时,不起作用。


var dados:XML = new XML();
dados.ignoreWhite = true;
dados.load("xml/15anos.xml");
dados.onLoad = function():Void  {
qtd = this.childNodes[0].childNodes.length;
for (j = 0; j <= qtd; j++) {
mcPanels.item_mc.duplicateMovieClip("item_mc" + j,mcPanels.getNextHighestDepth());
mcPanels["item_mc" + j].imagem = this.childNodes[0].childNodes[j].childNodes[0].attributes.imagem;
mcPanels["item_mc" + j].tamanho = this.childNodes[0].childNodes[j].childNodes[1].attributes.tamanhofoto;

mcPanels["item_mc" + j].foto.loadMovie(mcPanels["item_mc" + j].imagem);

mcPanels["item_mc" + j]._x = j * mcPanels["item_mc" + j].tamanho; mcPanels["item_mc" + j]._y = 0;}}

1 个答案:

答案 0 :(得分:0)

感谢@Martin Coulthurst寻求帮助,在另一个问题上寻求解决方案!!!

这是解决方案:

dados.onLoad = function():Void  {
    qtd = this.childNodes[0].childNodes.length;
    _root.qualqtd = this.childNodes[0].childNodes.length;
    //track the width of the images

    var totalWidth:Number = 0;

    for (j = 0; j @= qtd; j++) {
        mcPanels.item_mc.duplicateMovieClip("item_mc" + j,mcPanels.getNextHighestDepth());
        mcPanels["item_mc" + j].imagem = this.childNodes[0].childNodes[j].childNodes[0].attributes.imagem;
        mcPanels["item_mc" + j].tamanho = Number (this.childNodes[0].childNodes[j].childNodes[1].attributes.tamanhofoto);
        mcPanels["item_mc" + j].foto.loadMovie(mcPanels["item_mc" + j].imagem);
        //dynamically set the x position based on previous image width
        mcPanels["item_mc" + j]._x = totalWidth;
        mcPanels["item_mc" + j]._y = 0;
        //store a reference to the new foto holder
        imageList.push(mcPanels["item_mc" + j]);

        //i assume you have the width in your xml
        totalWidth += mcPanels["item_mc" + j].tamanho;
    }
};