Archive for December 9th, 2008


Fun with Flash: Assembler

Have you ever wanted to take some element, and then make a cool animation where it is assembled from a thousand different pieces? Well, me neither, until I saw a cool video of it. Then I wanted to see if I could make a Flash tool for it. Take a look at the result here.


Getting it to work
The first issue was to figure out where all the squares would have to go. On a suggestion from a colleague, I tried to use flocking to find the positions, which is why the source contains all the code necessary to make the blocks behave like boids 🙂

However, I quickly realized, that what I would achieve with flocking could much more easily be determined simply by finding pixels that were colored, as those represent the final text. By adding in a check that surrounding pixels also had to be colored, the blocks more or less would end up within the desired shape.

Have you written code like “if( show && alpha < 1 ){ alpha += 0.1; }” many, many times? I have, and although you can fade in or out something with few lines of code, it gets old fast and adds some complexity to code that really should be about something else than fading in or out.

When I found this tweener library I was quickly sold. Not only will it let you easily fade things in and out, but it also allows for lots of other cool effects using many different transitions. I’ve added some of these transitions to the dropdown in Assembler, and the rest are trivial to add. For being trivial, they sure add some great effects and can change the overall feeling a lot.

End transition
Even with this effort and a great tween library, the squares still won’t fit the text completely. My solution here is to use PixelDissolve from one BitmapData to another, but it still looks a bit weird. I’ve thought about some better solutions, and will bring an update if I get around to trying them out.

Possible uses?
I only did this for fun and to see if I could. I never really thought about what it could be used for. If you have some ideas for games or anything cool this could be used for, then please let me know. I would love the inspiration 🙂

Download Source


December 2008