Experimenting: Flash AS3 Grid Sorting

January 21, 2009

Working on a project that required us to sort out a grid layout, we were experimenting with what the best methods would be to visually communicate the items on a vertically scrolling grid when resizing the window. Using a little AS3, I managed to code a few mad nerdy little examples. Of course, there isn’t any scrolling in these examples, but you get the point. Check them out here:

1) Left flush no-resize sorting : In this example, everything is flush left, and the grid items do not resize. Visually, it keeps the spacing consistent and everything in order, but leaves some whitespace.

2) Auto justify no-resize sorting : In this example, the grid items space out evenly to fit the screen and also do not resize. Visually, makes a good use of the gutters, but might look kinda funny.

3) Auto resizing, full screen sorting : All the grid items resize horizontally and vertically to fit the width of the screen. Visually, it makes the best use of the gutters, but stretches the images. So I guess this depends what sort of content you’re placing in the items. You may or may not want to stretch them.

4) Left flush no-resize smart sorting : This is the same as #1, but I call it smart, because it keeps the screen looking more filled. Once you resize the browser, you’ll notice that when your window is covering half of an item, it will appear/disappear. This hides some of the item, but gives some padding to make it feel more comfortable.

Download source files for all 4 examples here.

A lot of times, when you’re immersed in the design/development, you lose sight of the obvious and/or lose sight of what you’re actually trying to achieve. Are there other obvious options? Which method is the best out of these?

Let us know if you find these handy, or if you have any suggestions or comments!

12 Comments

kukejs August 31, 2010 at 1:00 pm

You just saved my life. Thanks man You rock!

Wouter August 19, 2010 at 12:48 pm

Awesome stuff, very very usefull! =D I especially think the third is great, perfect mix between resizing and scaling.

I do have a small tip though. I don’t know if it’s useful, but I noticed that if you stretch out too far, the right boxes will go out of the screen.

I did this:
var newBoxWidth:Number = (totalBoxWidth + ((stage.stageWidth – (padWidth*wideCount) /wideCount – boxWidth)));

instead of this:
var newBoxWidth:Number = (totalBoxWidth + ((stage.stageWidth/wideCount – boxWidth)));

Anyway thanks a lot for this, great great work!

arun shourie July 19, 2010 at 11:46 pm

that’s a cool tut… but how about the sorting with boxes of different width or height… will it work still?. thanks

Dimitris April 13, 2010 at 11:15 am

Thanks for sharing your code. I was wondering If you have an example with XML loaded images. I am trying to accomplish something similar by externally loading images through XML file.
The problem is that I cannot incorporate the loop that sorts the grid (i mean i don’t want to reload the xml file every time the browser resizes…)

simon February 8, 2010 at 4:17 am

very usefull, thanks

dorian February 4, 2010 at 12:32 am

so great!
Many thanks.

dsimoes January 21, 2010 at 3:45 pm

Impressive. I was preety close to a solution for the same issue, but yours is much easier than mine.

I guess you beat me on this one :)

Cheers.

Pedro January 6, 2010 at 4:32 pm

Thank you so much for sharing your code =]
Great work btw!

Will January 4, 2010 at 2:34 am

You could also simplify your Example 1 grid calculations to this:

var rowNum:Number = Math.floor(n/wideCount);
var columnNum:Number = n % wideCount;

Badass, and thanks again!

Will January 4, 2010 at 1:57 am

These are great! Nicely done, and many thanks!

noponies February 5, 2009 at 5:48 pm

Cool examples!

Frank January 25, 2009 at 10:46 am

nice! this is useful.

Leave a comment

 

Categories

Archives

Recent

RSS

About Rareview

In 2002, we started as a small group interested in creating lasting, progressive web applications that pushed the envelope. Today, as a small interactive agency in Los Angeles, we still have that same desire and feed off new challenges from clients and technology. We are fortunate to have plenty of great clients who give us creative freedom and leeway to redefine ourselves with each new project. To learn more visit our website at www.rareview.com.

We have also designed and built our own Project Management Application that's available for everyone. You can learn more, watch a video tour, and sign up for a free trial at www.projecturf.com.