Flash Grid Layout Example

In the example below, there is a Grid LayoutManager populated with circles. Unlike the first example, this example has the property useFixedSizes set to true. In the text boxes, you can change the width and heights of the columns and rows by entering in either a number, or a percent (e.g. 34%).

The magic functions, previously undocumented, are setRowSizes, and setColSizes

layoutManager = new GridLayout_3_0(this, 3, 4); // root_mc, rows, cols
layoutManager.x = 0;
layoutManager.y = 0;
layoutManager.width = 500;
layoutManager.height = 400;
layoutManager.useFixedSizes = true;
layoutManager.setRowSizes(23, 43, "24%");

These methods are overloaded.
Usage 1:
setRowSizes(23, 43, null, "24%");
This will set row 1 to 23px, 2 to 43px, 4 to 24% of remaining space, and rows 3 and any rows after 4 will share the remaining space evenly.

Usage 2:
var my_arr:Array = [23, 43, null, "24%"];
Same as usage 1, just using an array instead of multiple arguments.

Usage 3:
This will set every row to 23 pixels. (Can also use a percent, or null to distribute all space evenly.)

The same overloading applies to the method setColSizes.

For a simple introduction to my layout managers, click here.

This site requires the Flash player to display correctly. Go to http://www.adobe.com/go/getflash/ to download this plugin.

layoutManagersExample2.zip22.06 KB
layoutManagersSrc2.zip19.64 KB

It's been years since I've used these, but there's a draw function or something like that you can call at any time to refresh them.


Thanks for posting these, it's probably worth pointing out that this works fine for simply sprites but if you have sprites which have event listeners inside of them it seems to break the manager. I managed to get an example working fine but as soon as I used Loader classes (to load images into) inside the clips I wanted to arrange it stopped the manager from working.