Skip navigation
Currently Being Moderated

detect inactivity mouse

Dec 23, 2011 10:43 PM

Hello:

 

I have one principal menu with six buttons, each button open (in a loader) new menues flash movies, one of them flash movie, for example, has 20 buttons each button open in a loader a  new movie. I need to detect inactivity for ten minutes for example and come back to the principal menu. Do I have tu put the code in all movies or there is a way tu put only in the movie with 20 buttons?

 

thank you very much

 
Replies
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 24, 2011 7:02 AM   in reply to anjemalo

    your main swf can detect events in all loaded swfs.  so, if you wanted to detect 10min mouse inactivity, in your main swf:

     

    var t:Timer=new Timer(10000,0);

    t.addEventListener(TimerEvent.TIMER,timeoutF);

    t.start();

    this.addEventListener(MouseEvent.MOUSE_MOVE,moveF);

     

    function moveF(e:MouseEvent):void{

    t.reset();

    t.start()

    }

    function timeoutF(e:TimerEvent):void{

    // do whatever because of mouse inactivity

    }

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 24, 2011 10:41 PM   in reply to kglad

    if you no longer need the timer after one timeout, use:

     

     

    var t:Timer=new Timer(10000,0);

    t.addEventListener(TimerEvent.TIMER,timeoutF);

    t.start();

    this.addEventListener(MouseEvent.MOUSE_MOVE,moveF);

     

    function moveF(e:MouseEvent):void{

    t.reset();

    t.start()

    }

    function timeoutF(e:TimerEvent):void{

    // do whatever because of mouse inactivity

    t.removeEventListener(TimerEvent.TIMER,timeoutF);

    t=null;

    }

     
    |
    Mark as:
  • kglad
    72,213 posts
    Jul 21, 2002
    Currently Being Moderated
    Dec 25, 2011 7:02 AM   in reply to anjemalo

    1.  to unload a loaded swf, apply unloadAndStop(), if you're publishing for fp10+, to the loader or unload().

     

    2.  to reset the timer, apply reset() to the timer.   to restart the timer, apply start() to the timer.  both are showing in moveF()

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points