AS3 BinaryConversion Utility

There are certain utility classes one would expect to have been included as part of the Flash Player API or the Flex framework, however they do not always exist.

For instance, I have been working with binary data and needed an API which would convert Decimal Numbers to their Binary equivalents, however after spending some time searching the packages on livedocs I realized that nothing had been provided. So I decided to roll my own.

The BinaryConversion utility is an all static class which will convert decimal numbers to their 4, 8, 16 or 32-bit binary equivalents, respectively. For the most part you may never need to use this API unless you need to convert decimal numbers to specific binary equivalents, however it is very useful if you need a quick Decimal to Binary conversion utility which also provides bit range validation.

You can view the BinaryConversion example as well as the source code.

BinaryConversion is protected under the MIT license.

{ 2 comments to read ... please submit one more! }

  1. What is wrong with the .toString(2) method on numbers?

    I might be missing something here though…

    Greetz Erik

{ 0 Pingbacks/Trackbacks }