Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Date Completed: July 13, 2017
- // Purpose: Converting ounces to grams
- // This line makes the button, btnConvert wait for a mouse click
- // When the button is clicked, the determineConversion function is called
- btnConvert.addEventListener(MouseEvent.CLICK, determineConversion);
- // This is the determineConversion function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function determineConversion(e:MouseEvent):void
- {
- //Declare the variables for the while statements
- var Ounces:Number = 1;
- var Grams:Number;
- //Introduce the while statement for converting Ounces to Grams from 1 to 15 ounces
- while (Ounces <=15)
- {
- //Convert Grams to Ounces, add it to the Grams column with a fixed decimal point (2), add a new line, add the Ounces to the Ounces column, add a new line, add 1 to the Ounces and repeat
- Grams = Ounces * 28.35
- lblGrams.text += Grams.toFixed(2) + "\r"
- lblOunces.text += String(Ounces) + "\r";
- Ounces++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement