Advertisement
BOT_Yokel

ICS3U1 Unit 1 Activity 4: Question 2

Jul 11th, 2017
88
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 displayDate function is called
  3. btnCalculate.addEventListener(MouseEvent.CLICK, displayDate);
  4.  
  5. // This line makes the textinput, txtinRadius wait for a mouse click
  6. // When the textinput is clicked, the clearLabels function is called
  7. txtinYear.addEventListener(MouseEvent.CLICK, clearLabels);
  8.  
  9. // This is the displayDate function
  10. // e:MouseEvent is the click event experienced by the button
  11. // void indicates that the function does not return a value
  12. function displayDate(e:MouseEvent):void
  13. {
  14.     // declare the variables
  15.     var Year:Number;
  16.     var Avalue:Number;
  17.     var Bvalue:Number;
  18.     var Cvalue:Number;
  19.     var Dvalue:Number;
  20.     var Fvalue:Number;
  21.     var Gvalue:Number;
  22.     var Hvalue:Number;
  23.     var Ivalue:Number;
  24.     var Jvalue:Number;
  25.     var Kvalue:Number;
  26.     var Mvalue:Number;
  27.     var Month:Number;
  28.     var Day:Number;
  29.  
  30.     // calculate the Month and Date
  31.     Year = Number(txtinYear.text)
  32.     Avalue = Year % 19
  33.     Bvalue = Year / 100
  34.     Cvalue = Year % 100
  35.     Dvalue = Bvalue / 4
  36.     Kvalue = Bvalue % 4
  37.     Fvalue = ((8* Bvalue) + 13) / 25
  38.     Gvalue = (( 19 * Avalue) + Bvalue - Dvalue - Fvalue + 15) % 30
  39.     Hvalue = (Avalue + ( 11 * Gvalue)) / 319
  40.     Ivalue = Cvalue / 4
  41.     Jvalue = Cvalue % 4
  42.     Mvalue = ((2 * Kvalue) + (2 * Ivalue) - Gvalue - Hvalue - Jvalue + 32) % 7
  43.     Month = (Gvalue - Hvalue + Mvalue + 90) / 25
  44.     Day = (Gvalue - Hvalue + Mvalue + Month + 19) % 32
  45.  
  46.     // put the values into the labels
  47.      lblMonth.text = Month.toFixed(0);
  48.      lblDay.text = Day.toFixed(0);
  49. }
  50.  
  51. // This is the clearLabels function
  52. // e:MouseEvent is the click event experienced by the textinput
  53. // void indicates that the function does not return a value
  54. function clearLabels(e:MouseEvent):void
  55. {
  56.     txtinYear.text = "";
  57.     lblMonth.text = "";
  58.     lblDay.text = "";
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement