07.12.2012 Views

Adobe Director Basics

Adobe Director Basics

Adobe Director Basics

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ADOBE DIRECTOR BASICS<br />

3D: Controlling action<br />

#timeMS: Register a handler for the #timeMSevent to trigger that handler at a given interval a given number of<br />

times.<br />

Ways to register<br />

Use the following methods to register a callback handler:<br />

Use member3D.registerForEvent() to register a handler to be called whenever the given event is triggered by any<br />

model.<br />

Use node.registerScript() to register a handler to be called only when the given event is triggered by a particular node<br />

Use model.collision.setCollisionCallback(...) as a shortcut for model.registerScript(#collideWith, ...)<br />

For example, if you want information about all collisions in the member “3D” to be channeled to the on<br />

CollisionDetected() handler in a Movie Script, use the following commands:<br />

-- Lingo syntax<br />

member("3D").registerForEvent(#CollideAny, #CollisionDetected, 0)<br />

// JavaScript syntax<br />

member("3D").registerForEvent(symbol("CollideAny"), symbol("CollisionDetected"), 0);<br />

If you want information about collisions with model 1 (named “Dark”) in the member “3D” to be channeled to the on<br />

DarkImpact() handler of an instance of the script “Dark Events”, use the following commands:<br />

-- Lingo syntax<br />

vInstance = new script("Dark Events")<br />

member("3D").model("Dark").collision.setCollisionCallback(#DarkImpact, vInstance)<br />

// JavaScript syntax<br />

vInstance = new script("Dark Events");<br />

member("3D").getPropRef("model", 1).getPropRef("collision",<br />

1).setCollisionCallback(symbol("DarkImpact"), vInstance);<br />

To send information on all animations that start playing in member “3D” to an on ShowMotionDetails() handler<br />

in a behavior on sprite 2, use the following code:<br />

-- Lingo syntax<br />

member("3D").RegisterForEvent(#animationStarted, #ShowMotionDetails, sprite 2)<br />

// JavaScript syntax<br />

member("3D").RegisterForEvent(symbol("animationStarted"), symbol("ShowMotionDetails"),<br />

sprite(2));<br />

To call the on SecondThoughts() handler in a behavior in the script “MetroGnome” every 1000 milliseconds exactly<br />

60 times, starting 42 milliseconds from now, use the following code:<br />

-- Lingo syntax<br />

member("3D").RegisterForEvent(#timeMS, #SecondThoughts, script "MetroGnome", 42, 1000, 60)<br />

// JavaScript syntax<br />

member("3D").RegisterForEvent(symbol("timeMS"), symbol("SecondThoughts"), script<br />

"MetroGnome", 42, 1000, 60);<br />

Stopping callbacks<br />

You can use member3D.unregisterAllEvents() to stop all callbacks to all handlers in all scripts for all events.<br />

Note: In <strong>Director</strong> 11.5, there is no way to unregister just one handler for one event. Design your scripts so that this<br />

functionality is not required.<br />

Last updated 8/26/2011<br />

357

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!