SpringyTiles : break an image into tiles that spring to place

March 12th, 2008 . by polyGeek

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.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Digg
  • Facebook

Leave a Reply

Name

Mail (never published)

Website

- Why ask? This confirms you are a human user!

   




© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites