Guest User

Untitled

a guest
Jan 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. // When the button btnTest is clicked the displayTest function is called
  2. btnTest.addEventListener(MouseEvent.CLICK, displayTest);
  3.  
  4. // When the mouse is clicked inside "txtinNumber1" the clearLabels function is called
  5. txtinNumber1.addEventListener(MouseEvent.CLICK, clearLabels);
  6.  
  7. // e:MouseEvent or KeyDown - click or keyboard event experienced by the button
  8. // void - the function does not return a value
  9. function displayTest(e:MouseEvent):void {
  10.  
  11. HELP HERE -------------------
  12.  
  13. // If the ENTER key is pushed on the keyboard the displayTest function will be called
  14. key.removeListener(btnTest);
  15. this.onKeyDown = function() {
  16. if (key.isDown(key.ENTER)) {
  17. // action here
  18. }
  19. };
  20. key.addListener(btnTest);
  21.  
  22. // declare the variable
  23. var number1:int;
  24. var key:
  25.  
  26. // This is the clearLabels function
  27. // e:MouseEvent - click event experienced by the textinput
  28. // void - the function does not return a value
  29. function clearLabels(e:MouseEvent):void {
  30. txtinNumber1.text = "";
  31. lblAnswer.text = "";
  32.  
  33. // get the numbers from the user
  34. number1 = Number(txtinNumber1.text);
  35.  
  36. if (number1 == 18) {
  37. lblAnswer.text = "You may purchase alcohol in Alberta, Manitoba and Quebec." }
  38.  
  39. if (number1 <= 19) {
  40. lblAnswer.text = "You may purchase alcohol in all parts of Canada." }
  41.  
  42. if (number1 > 18) {
  43. lblAnswer.text = "You may NOT purchase alochol in Canada." }
  44.  
  45. }
  46. }
Add Comment
Please, Sign In to add comment