# getTimer opr setInterval

**URL:** <https://forum.kirupa.com/t/gettimer-opr-setinterval/6540>\
**Category:** flash\
**Created:** [October 10, 2002, 12:45am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540 "2002-10-10T00:45:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kidd\_Flash](https://avatars.discourse-cdn.com/v4/letter/k/b487fb/32.png) [@Kidd\_Flash](https://forum.kirupa.com/u/Kidd_Flash)\
**Post date:** [October 10, 2002, 12:45am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/1 "2002-10-10T00:45:30Z")

</div>

Hey, I’m trying to write a function that executes a code when no buttons on my site are pressed within a specific time. For example, if no one presses a button after 10 seconds, I want a certain function to run…how do I do this? Thank You…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 1:00am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/2 "2002-10-10T01:00:38Z")

</div>

Create an empty movieclip and attach this to it.

```auto

onClipEvent(enterFrame){
	myTimer = Math.round(getTimer()/ 1000);
	if(_root.pressing == false && myTimer > = 10){
		myFunction();
	}else{
		//do whatever!!
	}
}

Then on your buttons put

on(release){
    _root.pressing = true;
    //then add more actions
}

```

Hope this helps

Kyle

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 1:11am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/3 "2002-10-10T01:11:01Z")

</div>

Hey Kyle, thanks for the response. Now. do I create an empty MC like we did in Flash 5, or do I use the \_root.createEmptyMovieClip method in MX…thanx…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 1:19am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/4 "2002-10-10T01:19:29Z")

</div>

Perhaps I missed something but, won’t that code fail to work after a user clicks on a button once? Also, the function will continue to execute because it checks for the value constantly. I dont think this is what you want.

What I mean is:

user loads page: All is quiet for x amount of time, code executes

user loads page: user clicks one button: user stares at the screen for half an hour \*\*\*\*\* the code will not execute because the value of pressing has changed once.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 1:35am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/5 "2002-10-10T01:35:32Z")

</div>

I’m going 2 play with Flash now; I’ll post my results…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 2:02am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/6 "2002-10-10T02:02:42Z")

</div>

I would try this…

put this code in a frame

```auto

function countemup(){
	stoptime=gettimer()+6000; //this means six seconds
	empty.onEnterFrame=check=function(){
		
		if(getTimer()>stoptime){
			
		trace("function will happen");
		stoptime=getTimer()+6000;
	}
}
}
countemup();

```

of course, you still need the emptyclip, at least for this version.

put this code on all your buttons.

```auto

on(release){
	stoptime=gettimer()+6000; //um.. six seconds again
	trace("time reset, wait 6 seconds");
}

```

of course, change your time interval to anything you want. If you dont want to nag your users by repeating the functions… you could just set a variable that determines how many times you will bug them for being idle 🙂

Hope this makes sense to you. If not, let me know and I’ll be happy to explain.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 1:10pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/7 "2002-10-10T13:10:27Z")

</div>

Did it help?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 5:47pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/8 "2002-10-10T17:47:47Z")

</div>

Unfortunately not Iammontoya. Let me explain what I’ve tried to do to render a more clearer picture what I’m trying to do.

On a frame in the main timeline, for example, I have this code:

ChangeTime=getTimer()+10000;

Now, on my buttons, I have this code:

on (release){  
if(MyButton.onPress.onrollOver == false && ChangeTime\>=10000){  
function goBack();  
}

So, what I’m clearly trying to do is, have my goBack function execute if my buttton hasn’t been pressed within ten seconds, or any of my buttons for that matter. I know this is simple, but I’m just missing the switch. I appreciate any and all assistance.

I’ve read a similar tut somewhat helpful about this on flash kit; here’s the link

[http://www.flashkit.com/tutorials/Interactivity/Accessin-Thomas\_W-780/index.php](http://www.flashkit.com/tutorials/Interactivity/Accessin-Thomas_W-780/index.php)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 5:59pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/9 "2002-10-10T17:59:54Z")

</div>

Im baffled, because what I wrote will do exactly that.

As soon as you start your movie the counter will start. In this case it will count up to 6 seconds, unless a button is pressed. If a button is pressed, the counter starts over. How is this not what you were looking for?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 6:07pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/10 "2002-10-10T18:07:53Z")

</div>

I will retry it right now…maybe I did something amiss. I’ll post back…but let me ascertain something: where does this part of your code goes : “empty.onEnterFrame=check=function()” ?

Do I put that code on an empty movie clip’s frame, attach it to an empty movie clip with a handler, or that part of the codes goes on the main time line with the code that’s written above it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 6:25pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/11 "2002-10-10T18:25:50Z")

</div>

Iammontoya, it didn’t werk, and I coded everything the way you said. If you could prove that your code works by sending a fla. (a fla. of this sort should take a mere couple of minutes to make), I would appreciate it. If not, thanks so much for your help anyway.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 6:52pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/12 "2002-10-10T18:52:04Z")

</div>

here’s the code… I think I only added code for the top button (dont remember)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 10, 2002, 9:36pm UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/13 "2002-10-10T21:36:32Z")

</div>

Thanx alot 4 tha fla…I got everything working now after now…

Kidd Flash

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 11, 2002, 2:14am UTC](https://forum.kirupa.com/t/gettimer-opr-setinterval/6540/14 "2002-10-11T02:14:47Z")

</div>

good! For a second there I thought I was going crazy!
