Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This line makes the button, btnCalculate wait for a mouse click
- // When the button is clicked, the displayDigits function is called
- btnCalculate.addEventListener(MouseEvent.CLICK, displayDigits);
- // This line makes the textinput, txtinRadius wait for a mouse click
- // When the textinput is clicked, the clearLabels function is called
- txtinDigits.addEventListener(MouseEvent.CLICK, clearLabels);
- // This is the displayDigits function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function displayDigits(e:MouseEvent):void
- {
- // declare the variables
- var Initial:Number;
- var Hundreds:Number;
- var Tens:Number;
- var Ones:Number;
- var Remainder1:Number;
- var Remainder2:Number;
- var Sum:Number;
- // calculate the debt burden per year
- Initial = Number(txtinDigits.text)
- Remainder1 = Initial % 100
- Hundreds = (Initial - Remainder1) / 100
- Remainder2 = Remainder1 % 10
- Tens = (Remainder1 - Remainder2) / 10
- Ones = Remainder2 / 1
- Sum = Hundreds + Tens + Ones
- // put the values into the labels
- lblSum.text = Sum.toString();
- }
- // This is the clearLabels function
- // e:MouseEvent is the click event experienced by the textinput
- // void indicates that the function does not return a value
- function clearLabels(e:MouseEvent):void
- {
- txtinDigits.text = "";
- lblSum.text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement