What I meant was this.  There is only ONE "built-in" timer available. 
(Since I haven't used it in years, I just had to go look it up.)  You 
can start this timer by issuing a "startTimer" command, then check 
for how much time has expired by checking "the timer".  That's all 
fine and good.

However, think about what would happen if you have two events that 
you want to time - particular if they overlap in time.  Let's say 
that when some condition is met (the user clicks a button, etc.) 
using the "starttimer" you start a timer in a behavior attached to a 
sprite in channel 1.  While still in this frame (and the timer is 
running), some condition is met (the user clicks some other button), 
and you attempt to start a second timer, using "starttimer", in a 
behavior attached to a sprite in channel 2.  Well, since there is 
only ONE timer, that resets the timer that you were using in channel 
1.

Instead, it is recommended that you "remember" the point at which the 
event occured (saving either "the ticks" or "the milliseconds" into a 
variable, and do your own timing by doing a simple subtraction, e.g.,

property pStartTicks

on SomeEventWhereWeWantToStartATimer me
   pStartTicks = the ticks
   -- anything else you want to do here
end

on HowLongHasItBeen me
   theElapsedTicks = the ticks - pStartTicks
   -- anything else you want to do here, perhaps return theElapsedTicks
end

If you used a behavior that had code like this, then you could use as 
many "instances" (attach the behavior or one like it to as many 
channels) as you wish, and each instance would maintain its own 
timing information.  This way the timing in each channel would not 
interfere witht  the timing in any other channel.

Irv



At 9:49 PM +0800 5/6/02, noelle cheng wrote:
>>
>>>
>>>If multiple timers are required, you must create and manage your own.(�)
>>>Typically, you use the ticks property to track time in this manner.
>>>
>>>Is this the reason why timers should not be used ?
>>
>>There's no reason they shouldn't be used. There's nothing wrong 
>>with timing things. Sometimes you have to time things. (Like if you 
>>are making a quiz game and you want to give the user 30 seconds to 
>>answer a question.)
>
>
>Thanks, I understand this. But what did Irv mean, when he wrote this:
>
>�If you are doing timing somewhere else in your program, then there 
>might be an interaction�?  Does he mean  a  conflict?
>

-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to