1 Reply Latest reply on Oct 26, 2006 11:13 AM by kglad

    this code does not work, please help.

    Level 7
      Hello:
      I have this code and does not work. I need to detect the inactivity when the
      mouse or keyboard don't do anything it must --> loadmovie("book.swf",0);
      Can you help me please?
      Thank you

      //detect inactivity
      var Mouse:Object;
      var Key:Object;
      var time2Kill:Number;
      var count:Number;

      function init ()
      {
      Mouse = {};
      Key = {};
      time2Kill = 5000; //change seconds
      count = new Date ().getTime ();
      setListeners ();
      idInterval=setInterval (startCount, 1000);
      }

      function startCount ()
      {
      if (count < new Date ().getTime () - time2Kill)
      {
      //trace ("No activity");
      //clearInterval(idInterval);
      loadmovie("book.swf",0);
      } else
      {
      //trace ("works!!");
      }
      }

      function setListeners ()
      {
      mouse.onMouseMove = function ()
      {
      count = new Date ().getTime ();
      };
      key.onKeyDown = function ()
      {
      count = new Date ().getTime ();
      };
      Mouse.addListener (Mouse);
      Key.addListener (Key);
      }
      init ();