First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing! | Flash Jobs
Search tutorials
Author: Mr.Ehab

EXPLANATION

Let me tell you what numbers these systems have and the procedure I followed to convert a certain number from one system to another.
a. The decimal system takes numbers between 0 and 9 only
b. The Binary system takes 0 and 1 only
c. The Octal system that takes numbers between 0 and 7 only
d. The Hexadecimal system takes numbers between 0 to 9 in addition to the string charaters (A(10), B(11), C(12), D(13), E(14), F(15))

The procedure for converting is approximately common for all systems. I'll explain the simplest conversion (decimal to binary). If the user types 82 as a decimal number, I try to find all the numbers that are less than to this number such that these numbers are powers of 2. That is:
1, 2, 4, 8, 16, 32, 64 (and not 128)

Then, I write them inversely: 64, 32, 16, 8, 4, 2, 1

I take 64 and divide it by 82. I notice that there is one 64 in 82. The result is 1 (first digit in the binary system). I also compute the remainder, which is 18. Then I take 32 and divide it by 18 and notice that there is no 32 in 18 and the division yields zero. So, the first two digits in the binary number are 1 and 0. I proceed in the same manner until I get the binary number: 1010010.

Note: To convert to binary, we take powers of 2 and apply the same method. To convert to octal, we take powers of 8 and apply the same method. To convert to hexadecimal, we take powers of 16 and apply the same method.

The FLA file is available for download. Well, all we need is a single layer made up of 5 keyframes in the main timeline. The first keyframe contains the definitions of all the functions used. I used 6 functions that do the following:
1) Function decimalToHexadecimal that converts from decimal system to Hexadecimal system
2) Function decimalToOctal that converts from decimal system to octal system
3) Function binaryToDecimal that converts from binary system to decimal system
4) Function decimalToBinary that converts from decimal system to binary system
5) Function octalToDecimal that converts from octal system to decimal system
6) Function hexadecimalToDecimal that converts from hexadecimal system to decimal system

We'll go over the scripts of all these functions line by line to understand how they execute.

I used 4 radiobuttons from Common Libraries/Smart Clips that let the user chooses among the four number systems. For instance, if he chooses Decimal number system, then the second keyframe will be executed. When the user then types in the decimal number and presses the convert button, the corresponding number is converted to binary, octal, and hexadecimal using 3 dynamic variables that exist through out the last 4 frames in the main timeline. The dynamic variables are (output1, output2, and output3).

» Level Intermediate

Added: 2002-03-04
Rating: 5.95 Votes: 41
(10 being the highest)
» Author
Student studying Computer Engineering and Graphic Design.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.