Here's another script using timeOut objects in a behavior that can be
attached to multiple sprites.
Anthony
www.lifelinestudios.com
----------------------------------------------------------------------------
----------------------
property spriteNum
property poTimeOut -- unique timeout object reference
property pnTimerLength -- length of timer expressed in milliseconds
----------------------------------------------------------------------------
----------------------
on beginsprite (me)
-- get a unique name to use as a reference to the timeout object
poTimeOut = string(me)
-- set timer length
pnTimerLength = 2000
-- create a timeout object
oTemp = timeout(poTimeOut).new(pnTimerLength , #doSomething, me)
end beginSprite
----------------------------------------------------------------------------
--------------------------
on endSprite (me)
-- remove timout object|
me.removeTimeOutObject()
end endSprite
----------------------------------------------------------------------------
--------------------------
on doSomething (me)
-- do something here
-- remove timout object|
me.removeTimeOutObject()
end doSomething
----------------------------------------------------------------------------
--------------------------
on removeTimeOutObject (me)
-- remove timout object
timeout(poTimeOut).forget()
end removeTimeOutObject
----- Original Message -----
From: "James Newton" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, March 01, 2005 12:04 PM
Subject: Re: <lingo-l> Timer in Director
> On 3/1/05 5:30 PM, "Ali Aghighi" <[EMAIL PROTECTED]> wrote:
> > I have question about timers "starttimer" in director, If I can use
> > two timer at the same time, How I can define each timer for several
> > member?!?
>
> Hi Ali,
>
> There is only one "the timer". If you need more than one timing device,
you
> will need to roll your own:
>
> -- Timer ---------------------------------------
> -- (Parent script)
> ------------------------------------------------
>
> property pStartTime -- the milliseconds on new()
>
> on new(me)
> pStartTime = the milliseconds
>
> return me
> end new
>
>
> on TimeElapsed(me)
> return pStartTime - the milliseconds
> end
>
> ------------------------------------------------
>
> In the Message window:
>
> t = script("Timer").new()
> put t.TimeElapsed()
> -- 1431
>
> Cheers,
>
> James
>
> [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!]
>
[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!]