How to apply a 9-Slice scaling on a Bitmap

If you are trying to apply a 9-Slice scaling on a Bitmap, by now you have already found out that is a big pain in the butt. If you don’t know yet, a 9-Slice scaling can be activated by going in the properties of your symbol and check the proper button as showed in this image: If you do this you are pretty much telling Flash that you only want to scale the inside part of your MovieClip, this trick though only works for vectors (not even that good sometimes). So what to do in case you want to scale a Bitmap? You can use this approach, what I am doing here is very simple, I am dividing the image in 9 parts where the corners are always the same, and… [Read more »]


Air for Android – Blitting test on Motorola Xoom and Galaxy S 2

I have been trying different Android devices with Air for Android 3.1 and Blitting, I noticed the performance is very different on each of them, on my Galaxy S 2 it runs smooth but on Motorola Xoom lags very bad. I went on the Android Market and downloaded AirBench, it is an app that runs some tests on your phone and tells you the results. Some unrelated tests that stand out were these: Parse 145 KB XML file: Galaxy S 2 – 70ms Xoom – 150ms Allocate 8192 KB of Memory: Galaxy S 2 – 21ms Xoom – 36ms Write read and delete a 1024KB file: Galaxy S 2 – 64ms Xoom – 83ms   In my experiment I was running 30/30 FPS on GS2 and 16/30 FPS on Xoom, an impressive… [Read more »]

Motorola Xoom Android

Compress a String into Base64

This compression method is very helpful If you have a long string or any kind of byte array that you want to compress and then be able to put in a database or, for example, if you have a game with a level editor and you want to allow people to share levels with a code that you provide, hiding the actual variables you are using in that code and at the same time compressing it. Last year I have stumbled upon a SWC named Blooddy Crypto, it contains a wide variety of compressor and serialization, but most important, it’s fast as hell!  Download it and add it to your project. An example of code that show how to compress and uncompress:

It actually works better for longer strings, for example in this… [Read more »]

Complex Multiple Segments Inverse Kinematics

Yesterday I wrote a Simple class to handle simple Kinematics, but I was not very happy with it, I needed to use more segments, so I started looking around. I found this amazing experiment made with JavaScript (Source code) which really inspired me. Looks like the method used in this experiment is pretty valid and I found mentions of it in this two PDF regarding Inverse Kinematics for a Serial Chain with Joints under Distance Constraints and A fast, iterative solver for the Inverse Kinematics problem. The result of my experiments is this: Click on the stage to change to focused point or press any key to toggle the lock on the fixed points. The algorithm check recursively each point from the focus point and back, left and right. It can be pretty much explained with this… [Read more »]

IK Iterative

Simple Inverse Kinematics

I have been looking for a while with interest at how inverse kinematics works, on Wikipedia I found this page regarding the Law of cosines which sounds interesting, although looks overly complicated. Other methods to take in consideration are the Cyclic-Coordinate Descent (CCD) solution and a Jacobian matrix iterative solution. I have been able to determine the exact position of multiple joints using a mix of those, but the resulting algorithm looks ugly at least. So while I am looking to find a cute one enjoy this piece of code to calculate IK on 2 joints.