Posts Tagged ‘as3’

Flash Bitmap 9-Slice Scaling (AS3)

I actually wrote this last week for a project I’m working on, so imagine my surprise when I see Grant Skinner’s post on 9-slice scaling bitmaps in Flash.

His method uses a JSFL script to pre-slice bitmaps into separate MovieClips, which is great, because it’s otherwise a complete pain. Mine works on a different principle, and is for runtime use.

My Slice9Bitmap script uses the pixel data from the Bitmap passed into the constructor, then transfers the appropriate pixel data to each slice, ensuring perfect stretching. Attempting to stretch the entire bitmap beforehand is…messy (also, why you can’t do 9-slice scaling with pure CSS2/Javascript (outside of canvas)).

Currently, there is no boundary checking (other than for negative values), so it’s up to you to implement this. Alternatively, you could wait until I add more features (which could be anywhere from weeks to months, honestly).

View Slice9Bitmap demo
Download Slice9Bitmap.as

Also, if you’re not a hardcore Actionscript guy, Grant’s method is quite ideal.

Generative Art: Google Logo

I’ve been impressed with what the Processing community does with generative art, and Actionscript seems to be at a point where it can be used much like Processing. In that vein, I’ve been watching Mark Knol’s generative art for a while, and while I wanted to do something like it, I’ve never actually bothered to create sit down and start coding it up.

Today, I tried to recreate his work on the Google logo. While mine doesn’t seem to have as much depth or chaos, I think it turned out fairly well. With some tweaking, I could improve it, but for now I just wanted to put something out there.

Hope you like it!

Great Googly Moogly!

Great Googly Moogly!