Accessibility
Grant Skinner

Grant Skinner

CEO and chief architect
gskinner.com

Table of Contents

Created:
31 October 2005
User Level:
Advanced
Products:
Flash

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. You can learn more by visiting gskinner.com or gskinner.com/blog/.

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.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Flash 8 Professional

Tutorials and sample files:

Prerequisites

Basic knowledge of ActionScript and Flash

About the author

Grant Skinner is the CEO and chief architect of gskinner.com, a creative technology company with a focus on the Flash platform. He works with leading new media agencies and progressive corporate clients to create cutting-edge applications, campaigns, and multimedia pieces. His expertise in fusing coding with interface design, usability, marketing, and business logic has garnered international acclaim and resulted in a number of prestigious industry awards. Grant maintains an active blog at gskinner.com/blog/ and an exhibit of his experimental work at incomplet.org. Read more about Grant in the Flash: Ten years, ten perspectives series.