# Timer + round

**URL:** <https://forum.kirupa.com/t/timer-round/3026>\
**Category:** Uncategorized\
**Created:** [February 6, 2002, 7:00pm UTC](https://forum.kirupa.com/t/timer-round/3026 "2002-02-06T19:00:12Z")\
**Posts on this page:** 16\
**Page:** 1

<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:** [February 6, 2002, 7:00pm UTC](https://forum.kirupa.com/t/timer-round/3026/1 "2002-02-06T19:00:12Z")

</div>

I’m stupid!  
I can’t do anything right so I thought what the hell I’ll ask it at [kirupa.com](http://kirupa.com) …AGAIN…

OK the Timer  
The movie stops at frame 1 for 3 seconds and then goes to frame 2.  
(No textboxes that show the time that has passed or something… just the timer to count the seconds… or something…)

## Round I have a textbox var-named “tb” and I typed there “10.22222”. I want it to round the thing to 10.22

Geezuz I’m asking the same things I’ve asked before…  
Like I said I’m stupid 🙂

---

<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:** [February 6, 2002, 7:23pm UTC](https://forum.kirupa.com/t/timer-round/3026/2 "2002-02-06T19:23:50Z")

</div>

You can try that trick :  
you multiply by 100, floor it, and then divide by 100.  
Something like Math.floor (var\*100)/100.  
It should do.

pom 0]

---

<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:** [February 7, 2002, 2:50pm UTC](https://forum.kirupa.com/t/timer-round/3026/3 "2002-02-07T14:50:19Z")

</div>

And what does that supposed to do?  
I mean it does nothing. It just multiplies it by 100 and then divides it by 100 and the result logically is the same. I tried it out and there it is the same too.

---

<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:** [February 7, 2002, 6:23pm UTC](https://forum.kirupa.com/t/timer-round/3026/4 "2002-02-07T18:23:01Z")

</div>

Are you sure about that ??? 😉 Try with (Math.floor(var\*100))/100 ;  
pom 0]

What does it do, do you ask ? Simple : let’s say you have  
var = 1.23456789 ;  
var_100 = 123.456789  
Math.floor (var_100) = 123  
Divide it by 100 = 1.23  
What you wanted, isn’t 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:** [February 7, 2002, 6:53pm UTC](https://forum.kirupa.com/t/timer-round/3026/5 "2002-02-07T18:53:51Z")

</div>

There ! Put any two numbers, but try and make so that their division won’t be an integer. For instance 1 and 7, 2 and 9… Whaddya think ?

pom 0]

---

<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:** [February 8, 2002, 2:44pm UTC](https://forum.kirupa.com/t/timer-round/3026/6 "2002-02-08T14:44:15Z")

</div>

Hey! That works!  
It’s not rounding I mean if my number is 12.479 the rounded one should be 12.48 but that only makes it 12.47…  
But it’ll do…  
------No there’s one thing left: The timer :eek: -------

---

<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:** [February 8, 2002, 3:57pm UTC](https://forum.kirupa.com/t/timer-round/3026/7 "2002-02-08T15:57:45Z")

</div>

I don’t understand your problem with the timer.Can you explain it a little bit better ?  
And concerning the rounding, making it so that it really rounds things would be, in my method, very _disgraceful_ but there’s a way. There always is.

pom 0]

---

<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:** [February 8, 2002, 5:54pm UTC](https://forum.kirupa.com/t/timer-round/3026/8 "2002-02-08T17:54:28Z")

</div>

to round, change Math.floor to Math.round

---

<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:** [February 8, 2002, 6:01pm UTC](https://forum.kirupa.com/t/timer-round/3026/9 "2002-02-08T18:01:37Z")

</div>

I tried that. It didn’t seem to work. It looked pretty obvious… Maybe I used the “uncut” numbers ?

pom 0]

---

<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:** [February 8, 2002, 6:34pm UTC](https://forum.kirupa.com/t/timer-round/3026/10 "2002-02-08T18:34:38Z")

</div>

AAAAARRGGHHHH!  
This is driving me grazy! :mad:  
I made a movie where that roudning thing worked and I didn’t save it now I was gonna try change it Math.round and I made another movie but that’s not working… I think the problem’s in the action’s locaton…  
Where should I put it (on a keyframe/on a btn…) I can’t remember where I put it before…  
--------The timer—  
For example the movie plays and …lets say… in frame 50 I want it to stop for 3 seconds and then play on.  
I don’t want any textboxes that show the time or something just to start the timer and if the timer reaches 3 seconds play();

---

<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:** [February 8, 2002, 10:49pm UTC](https://forum.kirupa.com/t/timer-round/3026/11 "2002-02-08T22:49:05Z")

</div>

Don’t get GRAZY !! It’s probably just a problem of path. Relax, leave your comp and get back to it in an hour.  
About the timer, there’s a wonderphul script by… guess who ??? Dans le mille, Emile ! Suprabeener about that. Exactl what you want, and very well explained too.  
Here : [www.multimania.com/ilyaslamasse/timer/](http://www.multimania.com/ilyaslamasse/timer/)  
Take the fla.

pom 0]

---

<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:** [February 9, 2002, 9:16am UTC](https://forum.kirupa.com/t/timer-round/3026/12 "2002-02-09T09:16:49Z")

</div>

Ok but I don’t really understand that script exactly…  
that’s the thing with the textboxes showing time and stuff and I can’t take the time-showing script from the timer script apart so… That doesn’t make sense to me at all…  
In frame 39 there s pause(5);  
If I delete that it doesn’t make a pause there ok but if I delete script in frame 1 then it doesn’t pause either. These things are connected to each other …somehow… I can’t understand the script there…

---

<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:** [February 9, 2002, 9:42am UTC](https://forum.kirupa.com/t/timer-round/3026/13 "2002-02-09T09:42:04Z")

</div>

Yeah, that’s one though script indeed. But you are told how to use it, so…  
Anyway, here’s a little explanation, and if I’m wrong, Supra can come here and quick my ass…

In the main timeline :

```auto
 
MovieClip.prototype.pause = function(l){
&nbsp &nbsp &nbsp &nbsp stop();
&nbsp &nbsp &nbsp &nbsp attachMovie("timer","timer1",76);
&nbsp &nbsp &nbsp &nbsp timer1.init = getTimer();
&nbsp &nbsp &nbsp &nbsp timer1.l = l;
}

```

He likes that prototype thing… Supra, I mean. Very disconcerting when you’ve never seen anything like that. Anyway, what it means is : a movie clip can call that function, with an argument \* l\* which is the pause.  
The movie stops.  
You put an instance of the movie clip \* timer\*, aka \* pause\* and you name it \* timer1\*, on level 76 (not so important).  
Tou initialize the value \* init\* and \* l\* INSIDE THIS CLIP you’ve just created.  
**_YOU HAVE TO UNDERSTAND THAT THIS CODE DOESN’T MAKE THE PAUSE. WHAT DOES IS THE CODE INSIDE THE CLIP \* PAUSE_. THIS CODING IS JUST A WAY TO MAKE THE CLIP EASILY REUSABLE, THAT’S ALL** \*

In the clip “pause” :

```auto
 
onClipEvent(enterFrame){
&nbsp &nbsp &nbsp &nbsp time = getTimer()-_parent.init;
&nbsp &nbsp &nbsp &nbsp if((getTimer()-_parent.init)/1000>_parent.l){
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _parent._parent.play();
&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _parent.removeMovieClip();
&nbsp &nbsp &nbsp &nbsp }
}

```

Now, what do we have ? The part :

```auto
 
timer1.init = getTimer();

```

made the clip \* timer1\* get the time (getTimer ()) when it is launched. Here, the line :

```auto
 
time = getTimer()-_parent.init;

```

gets the number of milliseconds that have passed since the init. If this time/1000 (to turn it into seconds) is superior to the time span of the pause \* \_parent.l\*, you tell the movie to play, and you remove the pause clip.  
All those \* \_parent.parent\* things are a little bit difficult to grasp, but draw your situation on a sheet of paper, and it all becomes clear (hum…).

I hope you understand it better now.

pom 0]

---

<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:** [February 9, 2002, 1:10pm UTC](https://forum.kirupa.com/t/timer-round/3026/14 "2002-02-09T13:10:08Z")

</div>

huh… looking at that little script i feel like a total loser!  
ok would you please tell me how would you do a thing like…  
in frame 1-\> wait 3 seconds and gotoAndStop(2);  
how would you do that…  
I still havent totally understood the script there…

---

<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:** [February 11, 2002, 1:52pm UTC](https://forum.kirupa.com/t/timer-round/3026/15 "2002-02-11T13:52:47Z")

</div>

Still can’t understand it fully…

---

<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:** [February 11, 2002, 9:00pm UTC](https://forum.kirupa.com/t/timer-round/3026/16 "2002-02-11T21:00:45Z")

</div>

Hey, man everything is explained in the fla !! Just put the code pause (2); in the frame you want to pause (after you’ve exported the pause movie, of course).  
pom 0]
