• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

detect inactivity mouse

Community Beginner ,
Dec 23, 2011 Dec 23, 2011

Copy link to clipboard

Copied

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

TOPICS
ActionScript

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2011 Dec 24, 2011

Copy link to clipboard

Copied

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

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 24, 2011 Dec 24, 2011

Copy link to clipboard

Copied

Thank you very much.

How can remove the timer when finish?

I have used removeEventListener and don't stop the timer.

many thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 24, 2011 Dec 24, 2011

Copy link to clipboard

Copied

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 25, 2011 Dec 25, 2011

Copy link to clipboard

Copied

Thanks again.

I have other question:

I am in the main swf and a second, third... swf are loaded, when the timer is over how can I remove this second, third... swf and come back to main swf?

Other one If I am in the main swf and the timer is over how can I stay in the main swf?

Many many thanks to you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 25, 2011 Dec 25, 2011

Copy link to clipboard

Copied

Hello:

I have another problem, when I load new swf and move mouse in the loaded swf the timer continue don't reset.

thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2011 Dec 25, 2011

Copy link to clipboard

Copied

LATEST

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()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines