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 displayCircleProperties function is called
- btnCalculate.addEventListener(MouseEvent.CLICK, displayCircleProperties);
- // This line makes the textinput, txtinRadius wait for a mouse click
- // When the textinput is clicked, the clearLabels function is called
- txtinRadius.addEventListener(MouseEvent.CLICK, clearLabels);
- // This is the displayCircleProperties function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function displayCircleProperties(e:MouseEvent):void
- {
- // declare the constants
- const PI:Number = 3.14159;
- // declare the variables
- var radius:Number;
- var area:Number;
- var circumference:Number;
- // calculate the area and circumference of a circle
- radius = Number(txtinRadius.text);
- area = PI * radius * radius;
- circumference = 2 * PI * radius;
- // put the values into the labels
- lblArea.text = area.toFixed(2);
- lblCircumference.text = circumference.toFixed(2);
- }
- // 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
- {
- txtinRadius.text = "";
- lblArea.text = "";
- lblCircumference.text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement