firstly, sorry if this has come up elsewhere but i couldn’t find it…
i want to display a grid of video thumbnails, whose parameters are loaded from XML. the number of TNs is variable but the area in which to display them is of a fixed size. i’d like the number of rows/columns AND the TN’s size to vary to fill the available space, whilst maintaining the TN’s aspect ratio
e.g. display area is 200w x 300h and there are initially 10 TNs (which are 4:3 ratio, say):
3 columns and 4 rows of TNs 62 px x 46 (i think:ne:)
but if the number of TNs goes up to 30, or down to 3, i want the code to adapt, to give me a 6 x 8 grid or a 1 x 2 etc. hope that makes sense…
any pointers on the maths involved? thanks in advance.
well, it would obviously be two loops to build the grid. Then you’d need a couple conditional statements to variably build then depending on how many clips you have.
Grid building loop:
var x_var:Number = 0;
var var_y:Number = 0;
how_wide = 10
how_tall = 10
while (var_y<=how_tall) {
while (var_x<=how_wide) {
var thumb:MovieClip = createEmptyMovieClip("video", getNextHighestDepth());
thumb._x = 10*var_x;
thumb._y = 10*var_y;
var_x++;
};
var_y++;
}
i am currently learning how to develop components in flash. and what i hv created is this functionality. however its not following the v2 framework of component as i am learning it but still i think it will certainly help you.
yeah - i’m pretty comfortable with the construction of the grid itself - what i’m stuck on is how to use AS to determine the correct number of rows and columns (and thus the TN dimensions) when only the grid area and the number of TNs is fixed.
i can see how to determine correct dimensions if only using one row or one column but having a grid complicates it and makes my head hurt .
sandeep - that looks like a nice component, and there’s some code in there i’ll have to study, but it doesn’t match my requirements, i.e. dynamic number of columns/rows based on total number of thumbnails.