Using Bitwise Operators to Manipulate Bits and Colors
Note: This article is part of a series of articles on new Flash 8 features written by the staff of gskinner.com, a Flash development and consulting company working with leading new media agencies and progressive corporate clients to create cutting-edge applications, games and, multimedia pieces.
As the T-shirt says, there are 10 types of people in the world: those who understand binary and those who don’t. If you got that (somewhat lame) joke, you’ve got a leg up. If not, don’t worry; you will shortly.
For the most part, Flash developers have been able to avoid learning binary math or bitwise operators. This is partly because of the highly abstracted nature of Flash (we’re not exactly writing assembly code here), partly due to the slow performance of bitwise operators in Flash relative to other languages, and partly due to the less formal programming educations that many of us have. Most importantly, until now there have been very few real reasons to utilize bitwise operations in Flash development.
That has all changed with Macromedia Flash 8. You now have the ability to work directly with pixels and color data, but are still very constrained by the processing limitations of the player. Bitwise operators offer a fast, relatively simple way to manipulate color data—once you figure out how to use them.
So I’ve dusted off my rusty knowledge of bitwise operators and how to apply them to color manipulation, and humbly present it in this article—just for you.
To complete this tutorial you will need to install the following software and files:
Macromedia Flash 8 Professional
Tutorials and sample files:
Basic knowledge of ActionScript and Flash
About the author
Grant Skinner is the CEO and chief architect of gskinner.com, a Flash development and consulting company. He works with leading new media agencies and progressive corporate clients to create cutting-edge applications, games, and multimedia pieces. His expertise in fusing coding with interface design, usability, marketing, and business logic has garnered him international acclaim and resulted in a number of prestigious industry awards, including Best Canadian Developer at FITC 2005.