Free Flash Tutorials

Home • Members Tutorials Forum iSnapChat Contact Us 


Flash Tutorials


Flash - Operators: Bitwise

503 ActionScript
Flash Compatibility: MX

Written by: Phil

Length: 2900 words

Assumed Knowledge : Standard Operators. This is NOT a tutorial for beginners


Access: Members Bonus tutorial. For the full version you must: LOG ON To become a Member: Click here


For Free Tutorials: See listings: Free Tutorials




Many people find bitwise operators confusing because they convert numbers back and forth from binary to decimal. Fortunately you do not need to use them very often! Alas there are times when you cannot avoid using them. The thing to do is focus on what the operator is doing rather than on the maths. Even if you know nothing about binary you can still use bitwise operators! After all it is the computer that does the maths not you.


When do you have to use Bitwise Operators?

Bitwise operators are not used that often but there are some occasions when it is the best solution:

  1. If you want to change the colour of something dynamically. By dynamically I mean that you don't know in advance what the colour will be. So for example if you wanted to create a paint box that the user can control the colour of the brush or some other object in the Flash Movie. You may have a picture of a car and the viewer could mix any colour to see the result.

    Cross Ref: For a practical tutorial on how to change an objects colour using Bitwise operators see: Intermediate - Colour Sliders

  2. When the speed of processing equations is of paramount importance, such as in a fast moving game which may have a lot of mathematics and graphics for the computer to process. Bitwise calculations are as close as possible to the binary system used by computers so theoretically the calculations are done at much higher speed. I am not sure how much faster?

  3. Calculating Flag Variables is best done with Bitwise operators. A Flag variable is a way of using a single variable to keep track of multiple settings. You use different bits of the binary number to represent different settings. For example the last digit of the number may represent sound on or off: 0 being off and 1 being on. The next digit would represent another setting such as visibility on or off etc. That would mean that if your variable = 11 (in binary) the sound would be on, and movie clip visible. In this way you can use the binary number as a set of switches, turning many things on and off with a single number. Bitwise numbers have up to 32 digits (32bit) and so a single variable could change up to 32 settings.

    Example: Download the Flash file ActS 503a

    An example of Flag Variables used to switch visibility on and off.

Computers use this binary system to control all the hundreds of settings that are on your machine. Using Bitwise Operator should enable you to create lean movies. I used bitwise operators to create a fully functioning Paint program. It is 6kb in size! It may not be the best paint program in the world but at 6kb it will download instantly. See the second sample file from the Beginners tutorial: Create a Whiteboard or Blackboard (Note: The Drawing Tutorial covers drawing online not Bitwise operators - although the sample uses bitwise operators).


This is a members only bonus tutorial. For the full text you must: LOG ON

For a full list of Free tutorials click here



Phil Schulz's Facebook Profile
Webwasp is Phil Schulz's baby. You are welcome to contact me or become my Facebook friend: Click here

 Top of Page HomeMembers Tutorials Forum iSnapChat Contact Us 
 All material on this site is protected under international copyright © law. DO NOT reproduce any material from this site without written permission. Please ask as permission is often granted.