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

vector1 = vector(3, 4, 5)<br />

vector2 = vector(5, 12, 13)<br />

trace(vector1.distanceTo(vector2))<br />

-- 11.4891<br />

trace(vector2.distanceTo(vector1))<br />

-- 11.4891<br />

put (vector1 - vector2).magnitude<br />

-- 11.4891<br />

put (vector2 - vector1).length<br />

-- 11.4891<br />

Note: Subtracting one vector for another is not permitted in JavaScript.<br />

For two vectors, both of which represent a translation or a direction, it is meaningful to calculate the angle between<br />

them. See vector.angleBetween() for more information.<br />

The angle between two direction vectors will be in the range 0.0 (if the vectors are parallel) to 180.0 degrees (if they<br />

are pointing in opposite directions).<br />

If one vector is pointing North and the second vector is at 135° to it, you cannot tell whether the second vector is<br />

pointing South-East or South-West. To distinguish between the two cases, you will also need to know which direction<br />

is Up. The vector.crossProduct() (see below) of the two vectors will point either up or down, depending on whether<br />

the second component points more or less East, or not.<br />

Binary operations<br />

A scalar is a one-dimensional number, such as 42, -0.7071, pi or _movie.frameTempo. The table below shows you<br />

what addition, substraction, multiplication, and division operations are permitted between scalars and vectors, vectors<br />

and vectors, and transforms and vectors. Note that some operations are meaningless, and fail silently. Other<br />

meaningless operations lead to a script error.<br />

Operation Description Output<br />

scalar + vector1orvector1 + scalar Returns a new vector equaling<br />

vector(vector1.x+scalar,<br />

vector1.y+scalar, vector1.z+scalar)<br />

scalar - vector1 Returns a new vector equaling vector(scalarvector1.x,<br />

scalar-vector1.y, scalarvector1.z)<br />

vector1 - scalar Returns a new vector equaling<br />

vector(vector1.x-scalar, vector1.yscalar,<br />

vector1.z-scalar)<br />

vector * scalarorscalar * vector Returns a new vector with the same direction as<br />

vector and a length equal to vector.length *<br />

scalar<br />

vector / scalar Returns a new vector with the same direction as<br />

vector and a length equal to vector.length /<br />

scalar<br />

Last updated 8/26/2011<br />

A new vector object<br />

A new vector object<br />

A new vector object<br />

A new vector object<br />

A new vector object<br />

scalar / vector Operation not supported *** Script error ***<br />

vector1 + vector2 Returns a new vector equal to<br />

vector(vector1.x+vector2.x,<br />

vector1.y+vector2.y,<br />

vector1.z+vector2.z)<br />

A new vector object<br />

367

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

Saved successfully!

Ooh no, something went wrong!