Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Date Completed: July 12, 2017
- // Purpose: Calculating sustainability of Fish according to pH of water
- // This line makes the button, btnRisk wait for a mouse click
- // When the button is clicked, the determineEligibility function is called
- btnRisk.addEventListener(MouseEvent.CLICK, determinePH);
- // This line makes the textinput, txtinLevel wait for a mouse click
- // When the textinput is clicked, the clearLabels function is called
- txtinLevel.addEventListener(MouseEvent.CLICK, clearLabels);
- // This is the determinepH function
- // e:MouseEvent is the click event experienced by the button
- // void indicates that the function does not return a value
- function determinePH(e:MouseEvent):void
- {
- // declare the variables
- var sustainability:Number;
- // get the pH level
- sustainability = Number(txtinLevel.text);
- // determine if the pH will sustain fish in water
- if (sustainability <= 7.5 && sustainability >= 6.5)
- {
- lblWarning.text = "NEUTRAL - FISH IN STREAMS, RIVERS AND LAKES WILL SURVIVE.";
- }
- else if (sustainability > 7.5)
- {
- lblWarning.text = "TOO ALKALINE - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE";
- }
- else if (sustainability < 6.5)
- {
- lblWarning.text = "TOO ACIDIC - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE";
- }
- }
- // 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
- {
- lblWarning.text = "";
- txtinLevel.text = "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement