Shuffle an Image and AIR

I’ve seen a couple blog posts recently from Emanuele Feronato about shuffling an image using the BitmapData class in Flash. It’s a great overview and I highly recommend checking it out if you’re into image manipulation with Flash. I remember the days when such effects were only possible through movie clip duplication and heavy use of masking. What I thought was interesting however, is that he uses an image linked in from the library.

First off, it is highly likely that you may want to perform this type of manipulation to an image that’s already in your library. You could of course also load an external image, assuming it came from the same domain as the SWF itself. But what if you wanted to let the user specify a random image from the web - say something from their Flickr account?

The problem with using just any old image is the security sandbox limitations of the Flash Player. If you’re going to manipulate images, they must come from the same domain as the SWF itself. The exception to this rule however is Adobe AIR. In addition to removing this restriction, AIR also provides the ability to incorporate native integration such as dragging-and-dropping an image file from the local machine into Flash.

Okay! Great! And?! Is there a point here, Kevin?

As it turns out, I had actually begun a similar image shuffle project during the third leg of the AIR Bus Tour. I think I was absorbing creativity through osmosis from Grant Skinner, who was also on that last leg of the tour. The idea for the AIR application was to provide a simple image shuffle game, where the user supplied whatever image they wanted.

on-air-shuffle.jpg

I started off with the aforementioned dragging-and-dropping of an image into the application, and having it automatically break it apart and shuffle it. Since the game board is square and most images are rectangular in nature, I also wrote some limited image cropping/resizing. Finally, I also kept track of the game board state, and allowed the user to click on a piece to move it (there is after all only one direction a piece can move).

The sad part of all this is that while the game is 90% complete, my time on the project has run out, and the game will likely never be finished. Rather than let that code go to waste however, and with a renewed interest in seeing others mention the concept, I thought that I’d simply make available what I have completed to this point. Take it for what it is - uncommented, untested code. If it proves useful, or if you finish the game, please let me know!

WordPress database error: [Can't open file: 'wp_comments.MYI' (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '133' AND comment_approved = '1' ORDER BY comment_date

Leave a Reply