Denis,

> I often need millisecond precision and I'm very interested by this. I 
> don't understand very well how to use the #target attribute of the 
> timeout object. I work out fine timeout() when the #timeoutHandler is 
> in a movie script - works great. But what does"  "The targetObject 
> identifies the name of the child object that contains the 
> #timeoutHandler" exactly means? The child of which parent? I 
> have tried with the #timeoutHandler in a member script, but it doesn't
> seem to work. I would be grateful if someone could provide a small 
> example.

Ok, imagine the following case:

-- behavior used as a frame script or attached to a sprite
-- that needs to create and use a timeout object
property pTimeout

on beginSprite (me) -- me is *required* here

  -- spawn the timeout object, give it an arbitrary name of "Denis
  -- Demo", have it fire off every 50 milliseconds calling the
  -- "doSomeStuff" handler found within this same behavior script
  pTimeout = timeout("Denis Demo").new(50,#doSomeStuff,me)

end beginSprite

on endSprite

  -- clear the timeout object
  pTimeout.forget()
  pTimeout = VOID

end endSprite

on doSomeStuff

  -- insert your timeout code here

end doSomeStuff

In the case above the "target object that contains the #timeOutHandler" is the 
behavior script itself, and that's where the "me" argument of the beginSprite handler 
comes into play. The "me" refers to that instance of the script when it's birthed into 
memory (to quote the script talking to you: "that timeout handler is in *me*"). If the 
timeout handler you want to specify is in another instanced script then you'll have to 
provide a reference to that birthed object instead of me:

pTimeout = timeout(...).new(50,#handler,ObjRef)

Where ObjRef can refer to a parent script object, another instanced behavior on a 
different sprite, etc. You can use the same information above to create your timeout 
object from within a movie script but have the timeout handler elsewhere (like in a 
behavior), it's just a matter of using the correct instanced script reference as the 
"target object".

Hope that helps.

Cheers,
Tom Higgins
Product Specialist - Director Team
Macromedia

...
[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