Tools object

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The Tools object is accessible from the flash object (fl.tools). The tools.toolObjs property contains an array of ToolObj objects, and the tools.activeTool property returns the ToolObj object for the currently active tool. (See also "ToolObj object" on page 500 and "Extensible tools" on page 24.)

NOTE

The following methods and properties are used only when creating extensible tools.


Method summary for the Tools object

The following methods are available for the Tools object.

Method

Description

tools.constrainPoint()

Takes two points and returns a new adjusted or constrained point.

tools.getKeyDown()

Returns the most recently pressed key.

tools.setCursor()

Sets the pointer to a specified appearance.

tools.snapPoint()

Takes a point as input and returns a new point that may be adjusted or snapped to the nearest geometric object.


Property summary for the Tools object

The following properties are available for the Tools object.

Property

Description

tools.activeTool

Read-only; returns the ToolObj object for the currently active tool.

tools.altIsDown

Read-only; a Boolean value that identifies if the Alt key is being pressed.

tools.ctlIsDown

Read-only; a Boolean value that identifies if the Control key is being pressed.

tools.mouseIsDown

Read-only; a Boolean value that identifies if the left mouse button is currently pressed.

tools.penDownLoc

Read-only; a point that represents the position of the last mousedown event on the Stage.

tools.penLoc

Read-only; a point that represents the current location of the mouse.

tools.shiftIsDown

Read-only; a Boolean value that identifies if the Shift key is being pressed.

tools.toolObjs

Read-only; an array of ToolObj objects.


tools.activeTool

Availability

Flash MX 2004.

Usage

tools.activeTool

Description

Read-only property; returns the ToolObj object for the currently active tool.

Example

The following example saves an object that represents the currently active tool in the theTool variable.

var theTool = fl.tools.activeTool;

tools.altIsDown

Availability

Flash MX 2004.

Usage

tools.altIsDown

Description

Read-only property; a Boolean value that identifies if the Alt key is being pressed. The value is true if the Alt key is pressed, and false otherwise.

Example

The following example determines whether the Alt key is being pressed.

var isAltDown = fl.tools.altIsDown;

tools.constrainPoint()

Availability

Flash MX 2004.

Usage

tools.constrainPoint(pt1, pt2)

Parameters

pt1 and pt2 specify the starting-click point and the drag-to point.

Returns

A new adjusted or constrained point.

Description

Method; takes two points and returns a new adjusted or constrained point. If the Shift key is pressed when the command is run, the returned point is constrained to follow either a 45° constrain (useful for something such as a line with an arrowhead) or to constrain an object to maintain its aspect ratio (such as pulling out a perfect square with the rectangle tool).

Example

The following example returns a constrained point:

pt2 = fl.tools.constrainPoint(pt1, tempPt);

tools.ctlIsDown

Availability

Flash MX 2004.

Usage

tools.ctlIsDown

Description

Read-only property; a Boolean value that is true if the Control key is pressed; false otherwise.

Example

The following example determines whether the Control key is being pressed.

var isCtrldown = fl.tools.ctrlIsDown;

tools.getKeyDown()

Availability

Flash MX 2004.

Usage

tools.getKeyDown()

Parameters

None.

Returns

The integer value of the key.

Description

Method; returns the most recently pressed key.

Example

The following example displays the integer value of the most recently pressed key in the Output panel.

var theKey = fl.tools.getKeyDown(); fl.trace(theKey);

tools.mouseIsDown

Availability

Flash MX 2004.

Usage

tools.mouseIsDown

Description

Read-only property; a Boolean value that is true if the left mouse button is currently down; false otherwise.

Example

The following example determines whether the left mouse button is pressed.

var isMouseDown = fl.tools.mouseIsDown;

tools.penDownLoc

Availability

Flash MX 2004.

Usage

tools.penDownLoc

Description

Read-only property; a point that represents the position of the last mouse-down event on the Stage. The tools.penDownLoc property comprises two properties, x and y, corresponding to the x,y location of the mouse pointer.

Example

The following example determines the position of the last mouse-down event on the Stage and displays the x and y values in the Output panel.

var pt1 = fl.tools.penDownLoc; fl.trace("x,y location of last mouseDown event was " + pt1.x + ", " + pt1.y)

See also

tools.penLoc

tools.penLoc

Availability

Flash MX 2004.

Usage

tools.penLoc

Description

Read-only property; a point that represents the current location of the mouse pointer. The tools.penLoc property comprises two properties, x and y, corresponding to the x,y location of the mouse pointer.

Example

The following example determines the current location of the mouse.

var tempPt = fl.tools.penLoc;

See also

tools.penDownLoc

tools.setCursor()

Availability

Flash MX 2004.

Usage

tools.setCursor( cursor )

Parameters

cursor An integer that defines the pointer appearance, as described in the following list:

  • 0 Plus cursor (+)

  • 1 black arrow

  • 2 white arrow

  • 3 four-way arrow

  • 4 two-way horizontal arrow

  • 5 two-way vertical arrow

  • 6 X

  • 7 hand cursor

Returns

Nothing.

Description

Method; sets the pointer to a specified appearance.

Example

The following example sets the pointer to a black arrow.

fl.tools.setCursor(1);

tools.shiftIsDown

Availability

Flash MX 2004.

Usage

tools.shiftIsDown

Description

Read-only property; a Boolean value that is TRue if the Shift key is pressed; false otherwise.

Example

The following example determines whether the Shift key is being pressed.

var isShiftDown = fl.tools.shiftIsDown;

tools.snapPoint()

Availability

Flash MX 2004.

Usage

tools.snapPoint(pt)

Parameters

pt specifies the location of the point for which you want to return a snap point.

Returns

A new point that may be adjusted or snapped to the nearest geometric object.

Description

Method; takes a point as input and returns a new point that may be adjusted or snapped to the nearest geometric object. If snapping is disabled in the View menu in the Flash user interface, the point returned is the original point.

Example

The following example returns a new point that may be snapped to the nearest geometric object.

var theSnapPoint = fl.tools.snapPoint(pt1);

tools.toolObjs

Availability

Flash MX 2004.

Usage

tools.toolObjs

Description

Read-only property; an array of ToolObj objects (see ToolObj object).

     < Day Day Up > 


    Developing Extensions for Macromedia Flash 8
    Developing Extensions for Macromedia Flash 8
    ISBN: 032139416X
    EAN: 2147483647
    Year: 2005
    Pages: 81

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net