Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Date Completed: July 12, 2017
- // Purpose: Calculating the possibility of forming a right angle triangle when given three side lengths
- // This line makes the button, btnRisk wait for a mouse click
- // When the button is clicked, the determineSum function is called
- btnDetermine.addEventListener(MouseEvent.CLICK, determineSum);
- // This line makes the textinput, txtinLevel wait for a mouse click
- // When a textinput is clicked, the clearLabel 1, 2, or 3 functions are called
- txtinSideA.addEventListener(MouseEvent.CLICK, clearLabel1);
- txtinSideB.addEventListener(MouseEvent.CLICK, clearLabel2);
- txtinSideC.addEventListener(MouseEvent.CLICK, clearLabel3);
- // This is the determineSum function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function determineSum(e:MouseEvent):void
- {
- // declare the variables
- var SideA:Number;
- var SideB:Number;
- var SideC:Number;
- // get the Side Lengths
- SideA = Number(txtinSideA.text);
- SideB = Number(txtinSideB.text);
- SideC = Number(txtinSideC.text);
- // determine if the square of a side length is equal to the sum of the remaining two side lengths
- if (SideA * SideA + SideB * SideB == SideC * SideC)
- {
- lblResult.text = "These sides can make a right-triangle.";
- }
- else if (SideB * SideB + SideC * SideC == SideA * SideA)
- {
- lblResult.text = "These sides can make a right-triangle.";
- }
- else if (SideC * SideC + SideA * SideA == SideB * SideB)
- {
- lblResult.text = "These sides can make a right-triangle.";
- }
- else
- {
- lblResult.text = "These sides cannot make a right-triangle.";
- }
- }
- // This is the clearLabel1 function
- // e:MouseEvent is the click event experienced by the textinput
- // void indicates that the function does not return a value
- function clearLabel1(e:MouseEvent):void
- {
- lblResult.text = "";
- txtinSideA.text = "";
- }
- // This is the clearLabel2 function
- // e:MouseEvent is the click event experienced by the textinput
- // void indicates that the function does not return a value
- function clearLabel2(e:MouseEvent):void
- {
- lblResult.text = "";
- txtinSideB.text = "";
- }
- // This is the clearLabel3 function
- // e:MouseEvent is the click event experienced by the textinput
- // void indicates that the function does not return a value
- function clearLabel3(e:MouseEvent):void
- {
- lblResult.text = "";
- txtinSideC.text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement