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 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 sum of any 2 side lengths is always greater than the remaining side length
- if (SideA + SideB <= SideC)
- {
- lblResult.text = "These sides cannot make a triangle.";
- }
- else if (SideB + SideC <= SideA)
- {
- lblResult.text = "These sides cannot make a triangle.";
- }
- else if (SideC + SideA <= SideB)
- {
- lblResult.text = "These sides cannot make a triangle.";
- }
- else
- {
- lblResult.text = "These sides can make a 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