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 displayRectangleProperties function is called
- btnCalculate.addEventListener(MouseEvent.CLICK, displayRectangleProperties);
- // This is the displayRectangleProperties function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function displayRectangleProperties(e:MouseEvent):void
- {
- // declare the variables
- var length:Number;
- var width:Number;
- var area:Number;
- var perimeter:Number;
- // calculate the area and perimeter of a square
- length = 30
- width = 35
- area = length * width;
- perimeter = length + width + length + width;
- // put the values into the labels
- lblLength.text = length.toString();
- lblWidth.text= width. toString() ;
- lblArea.text = area.toString();
- lblPerimeter.text = perimeter.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement