Arithmetic Operations

The slider is one of the components that come with Flash. We will use a slider to convert inches to centimeters. We will select the number of inches on the slider, and then multiply the number of inches by 2.54 to get centimeters.

Get Adobe Flash player
  1. Start a new ActionScript movie.
  2. From the menu select Window, Components (Ctrl+F7)
    slider component
  3. Select the Slider and drag it to the stage.
  4. Open the property window and change the name to sldInches and the maximum to 100:
    slider properties
  5. If you want, use the free transform tool to make the slider longer.
  6. Create a text box and name it lblInches. Add a second text box named lblCM.
    label inches
  7. Write the code as shown below.
1
2
3
4
5
sldInches.addEventListener(MouseEvent.MOUSE_MOVE,showInches);
function showInches(e:MouseEvent): void {
   lblInches.text=""+sldInches.value;
   lblCM.text=""+sldInches.value*2.54;
} //showInches
CODE
Download the flash file

NEXT: Convert Inches to Feet and Inches using %