8 Replies Latest reply on Feb 2, 2016 3:43 AM by Ned Murphy

    I have an error I don't understand...

    Sound1770

      We are new to flash and have been editing this clock. As we keep checking it things seem to be fine. Then we got a little deeper into it and a section throws an error. displayHour. 1180 Call to a possibly undefined method displyHour. There are two parts to this. displayMinute and displayHour. displayHour is the only one that throws an error. I have included a screenshot of the code. Any help would be appreciated. There are 3 errors and I marked the first one. It is about half way down

       

      Well the screenshot will not include all of it so I pasted it instead.

       

      time.text = getTime();

      function getTime(){

        var time = new Date();

        var hour = time.getHours();

        var minute = time.getMinutes();

        var second = time.getSeconds();

        var temp = "" + ((hour > 12)? hour - 12 : hour);

        temp += ((minute < 10) ? " :0" : ":") + minute;

        temp += ((second < 10) ? ":0" : ":") + second;

        temp += (hour >= 12) ? " pm" : " am";

        return temp;

      }

      day.text = getToday();

      function getToday(){

          var weekday_array:Array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");

          var today = new Date();

              var weekday:String = weekday_array[today.getDay()];

              var temp = weekday;

          return temp;

      }

      date.text = getDayz();

      function getDayz(){

        var month_array:Array = new Array("January","February","March","April","May","June","July","August","September","Octo ber","November","December");

        var calendar = new Date();

        var year = calendar.getFullYear();

           var number = calendar.getDate();

           var month:String = month_array[calendar.getMonth()];

           var temp = month + " " ;

        temp += (number + ", " + year);

        return temp;

      }

       

       

      var firstDelay:Number = 300;

      var tm:Timer = new Timer(firstDelay,0);

      var min:int = int(m_txtMinutes.text);

      var hr:int = int(h_txtHours.text);

      var chng:int = 1;

       

       

      tm.addEventListener(TimerEvent.TIMER,tmChange);

       

       

      m_btnInc.addEventListener(MouseEvent.MOUSE_DOWN, autoInc);

      m_btnInc.addEventListener(MouseEvent.ROLL_OUT, stopChange);

      stage.addEventListener(MouseEvent.MOUSE_UP, stopChange);

       

       

      m_btnDec.addEventListener(MouseEvent.MOUSE_DOWN, autoDec);

      m_btnDec.addEventListener(MouseEvent.ROLL_OUT, stopChange);

      stage.addEventListener(MouseEvent.MOUSE_UP, stopChange);

       

       

      h_btnInc.addEventListener(MouseEvent.MOUSE_DOWN, autoInc);

      h_btnInc.addEventListener(MouseEvent.ROLL_OUT, stopChange);

      stage.addEventListener(MouseEvent.MOUSE_UP, stopChange);

       

       

      h_btnDec.addEventListener(MouseEvent.MOUSE_DOWN, autoDec);

      h_btnDec.addEventListener(MouseEvent.ROLL_OUT, stopChange);

      stage.addEventListener(MouseEvent.MOUSE_UP, stopChange);

       

       

      function autoInc(mevt:MouseEvent):void {

       

      min++;

       

       

      displayMinute();

       

       

      chng = 1;

       

       

      tm.delay = firstDelay;

       

       

      tm.reset();

       

       

      tm.start();

       

      hr++;

       

       

      displayHour();         - This is the first of the errors

       

       

      chng = 1;

       

       

      tm.delay = firstDelay;

       

       

      tm.reset();

       

       

      tm.start();

       

       

       

      }

       

      function autoDec(mevt:MouseEvent):void {

       

       

      min--;

       

       

      displayMinute();

       

       

      chng = -1;

       

       

      tm.delay = firstDelay;

       

       

      tm.reset();

       

       

      tm.start();

       

      }

       

       

      hr--;

       

       

      displayHour();

       

       

      chng = -1;

       

       

      tm.delay = firstDelay;

       

       

      tm.reset();

       

       

      tm.start();

       

       

       

       

      function stopChange(mevt:MouseEvent):void {

       

       

      tm.stop();

       

       

      }

      function tmChange(tevt:TimerEvent):void {

       

       

      min += chng;

       

       

      displayMinute();

       

      }

       

       

      hr += chng;

       

       

      displayHour();

       

       

      if (tm.currentCount > 15) {

       

       

      tm.delay = firstDelay/5;

       

       

      return;

       

       

      }

       

       

       

      if (tm.currentCount > 5) {

       

       

      tm.delay = firstDelay/2;

       

       

      return;

       

       

      }

       

       

      function displayMinute():void {

       

       

      if (min > 60) {

       

       

      min -= 60;

       

       

      }

       

       

      if (min < 0) {

       

       

      min += 60;

       

       

      }

       

       

      if (min < 10) {

       

       

      m_txtMinutes.text = "0" + String(min);

       

       

      }

       

       

      else {

       

       

      m_txtMinutes.text = String(min);

       

      }

       

       

      function displayHour():void {

       

       

      if (hr > 12) {

       

       

      hr -= 12;

       

       

      }

       

       

      if (hr < 0) {

       

       

      hr += 12;

       

       

      }

       

       

      if (hr < 10) {

       

       

      h_txtHours.text = "0" + String(hr);

       

       

      }

       

       

      else {

       

       

      h_txtHours.text = String(hr);

       

       

      }

       

       

      }

       

       

      }