Quantcast
Channel: polyGeek.com » Actionscript 3
Viewing all articles
Browse latest Browse all 11

SpringyTiles : break an image into tiles that spring to place

$
0
0

I’ve been playing around with Bitmaps/BitmapData and came up with this. The main .as class loads an external image and then uses a Tiles.as class to break the image into rows/columns and then randomly position the tiles so that they can spring back into position.

The meat and potatoes of the work is done with the BitmapData.copyPixels() method:

bmpData.copyPixels( imgData, new Rectangle( c * w, r * h, w, h ), new Point() );

Where c and r stand for the current column/row.

The spring code is right out of Keith Peter’s Making Things Move for AS3 book, chapter 8, page 202. Thanks Kieth.

There’s a handful of features that I’d like to add to this just for funzies. If you think of something interesting tweak to add just comment and I’ll see about it.

And of course the source is well documented, mostly.

Note to FlexBuilder programmers: thanks for applying my code coloring preferences. But you missed the body:background-color. I had to manually add that. Otherwise it’s unreadable.

SpringyTiles : break an image into tiles that spring to place originally appeared on polyGeek.com on March 12, 2008.


Viewing all articles
Browse latest Browse all 11

Latest Images

Trending Articles





Latest Images