Element.left, Element.locked – Adobe Extending Flash Professional CS4 User Manual

Page 213

Advertising
background image

191

EXTENDING FLASH CS4 PROFESSIONAL

Element object

Example
The following example stores the Layer object that contains the element in the

theLayer

variable:

var theLayer = element.layer;

element.left

Availability
Flash MX 2004.

Usage

element.left

Description
Read-only property; a float value that represents the left side of the element. The value of

element.left

is relative to

the upper left of the Stage for elements that are in a scene and is relative to the symbol’s registration point (also origin
point
or zero point) if the element is stored within a symbol. Use

document.setSelectionBounds()

or

document.moveSelectionBy()

to set this property.

Example
The following example illustrates how the value of this property changes when an element is moved:

// Select an element on the Stage and then run this script.

var sel = fl.getDocumentDOM().selection[0];

fl.trace("Left (before) = " + sel.left);

fl.getDocumentDOM().moveSelectionBy({x:100, y:0});

fl.trace("Left (after) = " + sel.left);

See the

element.elementType

example.

element.locked

Availability
Flash MX 2004.

Usage

element.locked

Description
Property; a Boolean value:

true

if the element is locked;

false

otherwise. If the value of

element.elementType

is

"shape"

, this property is ignored.

Example
The following example locks the first element in the first frame, top layer:

// Similar to Modify > Arrange > Lock:

fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].locked = true;

Advertising