4 Replies Latest reply on Feb 10, 2008 1:41 PM by kglad

    how do I do this in actionscript 2?

    Flash_Forms_Question
      I was told my rollover should have a timer/interval that starts and after 1 second a function is called, and on rollout I should terminate the timer/interval. BUT they gave me the following 3.0 code and my site is in actionscript 2.0. Does anyone know how to do this?

      var myTimer:Timer = new Timer(1000, 1);
      myTimer.addEventListener(TimerEvent.TIMER, doFunction);

      myButton.addEventListener(MouseEvent.MOUSE_OVER, startDelay);
      myButton.addEventListener(MouseEvent.MOUSE_OUT, resetDelay);

      function startDelay(event:MouseEvent) {
      myTimer.start();
      }

      function resetDelay(event:MouseEvent) {
      myTimer.reset();
      }

      function doFunction(e:TimerEvent) {
      trace("Delayed 1 second!");
      }
        • 1. Re: how do I do this in actionscript 2?
          jc_2006 Level 1
          Try this. If I understand correctly I don't think you need the rollout function.

          myButton.onRollOver = function() {
          interval = setInterval(delay, 1000);
          }

          function delay() {
          clearInterval(interval);
          trace("Delayed 1 second!");
          }
          • 2. how do I do this in actionscript 2?
            Flash_Forms_Question Level 1
            I tried this solution, but i don't think it is working. see http://www.pxlforge.com/www.swf to see an example of the gallery page for which I want this script. The issue is I want the user to be able to zip across the gallery index buttons quickly without setting off the rollover. There are more rollovers on the large content area that some may never find because the content switches. I originally required a click to launch the detail content, but some were missing the detail images then.

            I placed your code on the first frame and adjusted it as follows...

            one.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            two.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            three.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            four.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            five.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            six.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            seven.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            eight.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            nine.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            ten.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            eleven.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            twelve.onRollOver = function() {
            interval = setInterval(delay, 1000);
            }

            function delay() {
            clearInterval(interval);
            }
            • 3. Re: how do I do this in actionscript 2?
              kglad Adobe Community Professional & MVP
              always use clearInterval() before your setInterval. and you need the rollOut methods to clearInterval() because you don't want to trigger a rollover after a an object's been rolled out..
              • 4. Re: how do I do this in actionscript 2?
                kglad Adobe Community Professional & MVP
                p.s. you posted as3 code in your original post. are you publishing for as3 or as2?