all groups > flash actionscript > january 2006 >
You're in the

flash actionscript

group:

Spacing dynamically loaded thumbnails.


Spacing dynamically loaded thumbnails. DadrianKaelan
1/29/2006 7:45:36 PM
flash actionscript:
I'm creating a thumbnail display that is loaded via an XML doc. Everything
works perfectly fine if I put the number of movie clips before hand (another
words create them on the Stage manually), however this defeats the purpose of
them being dynamic I suppose since I can only load a set amount at a time
before having to open the fla and edit things. My question is, does anyone know
code that would create a movieclip on the Stage with the same padding (space
inbetween) separating each MC and be able to maintain a set of roll over states
that I defined in an external Button Class definition (it simply works by
telling the MC to go to different labels in the button timeline to produce
different effects)? The way the layout goes is there's two MCs on one row, then
it goes downward from there with two more, and so on.

--Mike
Re: Spacing dynamically loaded thumbnails. ImagicDigital
1/29/2006 8:21:41 PM
Mike -

I just accomplished this (but I was shuffling the order of my thumbnails
before laying them out so my code ended up a bit different than what you'll
want). I got most of my code out of this thread (it's pretty long -- and
informative):


http://groups.google.com/group/macromedia.flash.actionscript/browse_frm/thread/9
6a25b5f552b07f1

It has posts from Rothrock, LuigiL, Pluda and Bal1977. They worked out
loading XML thumbnails/buttons in a grid, mostly using Rothrock's makeGrid
function:

-------------------------------
function makeGrid(numCols, numRows, xSpace, ySpace, xOffset, yOffset) {
var tmpArray = new Array();
var count = 0;
for (i=0; i<numRows; i++) {
for (j=0; j<numCols; j++) {
tmpArray = {x:xOffset+j*xSpace, y:yOffset+i*ySpace};
}
}
return tmpArray;
}

myGrid=new Array();
myGrid=makeGrid(4,4,100,120,0,0);

myClip1._x=myGrid.x;
myClip1._y=myGrid.y;
-------------------------------

Hope this helps; post again if you run into questions.
Re: Spacing dynamically loaded thumbnails. Rothrock
1/29/2006 8:44:53 PM
Thanks ImagicDigital for saving me the trouble of digging that out. Personally
I like it a lot. Hey I wrote it to solve my problem for doing the same kind of
thing.

If you have any questions regarding its use, let me know.
Re: Spacing dynamically loaded thumbnails. DadrianKaelan
1/29/2006 8:47:59 PM
First of all, that code is amazing...I hope I can do stuff like that some day.
But as far as understanding the basics of how it works, I'm pretty much there.
Thanks for the reply, this was a great help to me.

--Mike
AddThis Social Bookmark Button