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 />

vForceExertionMode = #kBoth<br />

vRestLength = 17.23<br />

vSpring = member("Physics").createSpring(vSpringDescriptor, vForceExertionMode, vRestLength)<br />

trace(vSpring)<br />

-- spring("spring")<br />

trace(vSpring.constraintType)<br />

-- #spring<br />

trace(vSpring.flags)<br />

-- #kBoth<br />

trace(vSpring.restLength)<br />

-- 17.2300<br />

Properties: differences and similarities<br />

Because they all require a ContstraintDesc object for their creation, all joints and springs have a shared set of<br />

properties: name, objectA, objectB, pointA, pointB, stiffness, and damping. They also share a constraintType<br />

property, which takes the value #angular, #linear, or #spring.<br />

Each constraintType has other properties to define its type-specific values. Angular joints and linear joints have a<br />

properties property, which is a property list.<br />

trace(vAngularJoint.properties) -- [#length: 23.5900]<br />

trace(vLinearJoint.properties)<br />

-- [#axis: vector( 0.9598, 0.0499, -0.2761 ), #angle: 56.0000]<br />

Attempting to access the non-existant properties property of a spring will lead to a script error. For a spring, you<br />

must use the flags and restLength properties.<br />

trace(vSpring.flags)<br />

-- #kBoth<br />

trace(vSpring.restLength)<br />

-- 17.2300<br />

Configurable properties<br />

For angular joints and linear joints, you can only change the values of the stiffness and damping properties. All the<br />

other properties are get-only. If you try to change the value of one of these other properties, a script error occurs. See<br />

“Angular joint properties” on page 334 and “Linear joint properties” on page 335 for more details.<br />

For springs, you can set the values of all the properties except name and constraintType. See “Spring properties” on<br />

page 336 for more details.<br />

Accessing joints and springs<br />

You can use the function physicsMember.getConstraint() to obtain a reference to either a spring or a joint as shown<br />

below:<br />

trace(member("Physics").getConstraint("angular"))<br />

-- constraint("angular")<br />

trace(member("Physics").getConstraint("linear"))<br />

-- constraint("linear")<br />

trace(member("Physics").getConstraint("spring"))<br />

-- spring("spring")<br />

Conversely, the physicsMember.getSpring() function will return a reference to a named spring, but will fail to find any<br />

constraint objects.<br />

Last updated 8/26/2011<br />

333

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

Saved successfully!

Ooh no, something went wrong!