Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Create an array to store a reference to each photo holder. In the onLoad function store the clip reference as you create it:</p> <pre><code>//create the imageList var imageList:Array =[]; dados.onLoad = function():Void { qtd = this.childNodes[0].childNodes.length; _root.qualqtd = 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; //store a reference to the new foto holder imageList.push(mcPanels["item_mc" + j]); } }; </code></pre> <p>Then in the moveIt() function, track the current clip and use its width to set the <em>targX</em> value:</p> <pre><code>function moveIt() { var imageWidth:Number = imageList[i]._width; trace("i" +i + "&lt; "+ imageWidth); if (dir == 1) { targX = Math.floor(mcPanels._x - imageWidth); i++; if (i == clipNum) { dir = -dir; } } else if (dir == -1) { targX = Math.floor(mcPanels._x + imageWidth); i--; if (i == 0) { dir = -dir; } } ... } </code></pre> <p>To layout the images with different widths, you need to track how wide each image is as you loop through. I assume <em>tamanho</em> is the width (sorry for my poor portuguese!)</p> <pre><code>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 = 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; } }; </code></pre> <p>hth</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload