How to create a grid based on random shapes?

How to create a "grid" using actionscript like the image below?

Basically you have an area of 1100x615 which should be filled with shapes that could be rotated and scaled...

Collision detection perhaps or something less cpu intensive for flash (as3) to manage?




You probably could adapt some of the word placement algorithms because in the end they place irregularly shaped polygons. There's wordle here and here An action script version here

A very nice javascript version is here

Note: If you are going to mobile you might want to consider optimizations because these packing algorithms can be computationally intensive. I used vector data elements for their speed and integers for numbers though floats might be ok on many devices.