Advertisement
BOT_Yokel

ICS3U1 Unit 1 Activity 3: Question 1

Jul 11th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This line makes the button, btnCalculate wait for a mouse click
  2. // When the button is clicked, the displayRectangleProperties function is called
  3. btnCalculate.addEventListener(MouseEvent.CLICK, displayRectangleProperties);
  4.  
  5. // This is the displayRectangleProperties function
  6. // e:MouseEvent is the click event experienced by the button
  7. // void indicates that the function does not return a value
  8. function displayRectangleProperties(e:MouseEvent):void
  9. {
  10.     // declare the variables
  11.     var length:Number;
  12.     var width:Number;
  13.     var area:Number;
  14.     var perimeter:Number;
  15.  
  16.    // calculate the area and perimeter of a square
  17.     length = 30
  18.     width = 35
  19.     area = length * width;
  20.     perimeter = length + width + length + width;
  21.  
  22.     // put the values into the labels
  23.     lblLength.text = length.toString();
  24.     lblWidth.text= width. toString() ;
  25.     lblArea.text = area.toString();
  26.     lblPerimeter.text = perimeter.toString();
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement