Edge object

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The Edge object represents an edge of a shape on the Stage.

Method summary for the Edge object

The following methods are available for the Edge object:

Method

Description

edge.getControl()

Gets a point object set to the location of the specified control point of the edge.

edge.getHalfEdge()

Returns a HalfEdge object.

edge.setControl()

Sets the position of the control point of the edge.

edge.splitEdge()

Splits the edge into two pieces.


Property summary for the Edge object

The following properties are available for the Edge object:

Property

Description

edge.id

Read-only; an integer that represents a unique identifier for the edge.

edge.isLine

Read-only; an integer with a value of 0 or 1.


edge.getControl()

Availability

Flash MX 2004.

Usage

edge.getControl(i)

Parameters

i An integer that specifies which control point of the edge to return. Specify 0 for the first control point, 1 for the middle control point, or 2 for the end control point. If the edge.isLine property is TRue, the middle control point is set to the midpoint of the segment joining the beginning and ending control points.

Returns

The specified control point.

Description

Method; gets a point object set to the location of the specified control point of the edge.

Example

The following example stores the first control point of the specified shape in the pt variable:

var shape = fl.getDocumentDOM().selection[0]; var pt = shape.edges[0].getControl(0);

edge.getHalfEdge()

Availability

Flash MX 2004.

Usage

edge.getHalfEdge(index)

Parameters

index An integer that specifies which half edge to return. The value of index must be either 0 for the first half edge or 1 for the second half edge.

Returns

A HalfEdge object.

Description

Method; returns a HalfEdge object.

Example

The following example stores the half edges of the specified edge in the hEdge0 and hEdge1 variables:

var shape = fl.getDocumentDOM().selection[0]; var edge = shape.edges[0]; var hEdge0 = edge.getHalfEdge(0); var hEdge1 = edge.getHalfEdge(1);

edge.id

Availability

Flash MX 2004.

Usage

edge.id

Description

Read-only property; an integer that represents a unique identifier for the edge.

Example

The following example stores a unique identifier for the specified edge in the my_shape_id variable:

var shape = fl.getDocumentDOM().selection[0]; var my_shape_id = shape.edges[0].id;

edge.isLine

Availability

Flash MX 2004.

Usage

edge.isLine

Description

Read-only property; an integer with a value of 0 or 1. A value of 1 indicates that the edge is a straight line. In that case, the middle control point bisects the line joining the two end points.

Example

The following example determines whether the specified edge is a straight line, and shows a value of 1 (it is a straight line) or 0 (it isn't a straight line) in the Output panel:

var shape = fl.getDocumentDOM().selection[0]; fl.trace(shape.edges[0].isLine);

edge.setControl()

Availability

Flash MX 2004.

Usage

edge.setControl( index, x, y )

Parameters

index An integer that specifies which control point to set. Use values 0, 1, or 2 to specify the beginning, middle, and end control points, respectively.

x A floating-point value that specifies the horizontal location of the control point. If the Stage is in Edit or Edit-in-place mode, the point coordinate is relative to the edited object. Otherwise, the point coordinate is relative to the Stage.

y A floating-point value that specifies the vertical location of the control point. If the Stage is in Edit or Edit-in-place mode, the point coordinate is relative to the edited object. Otherwise, the point coordinate is relative to the Stage.

Returns

Nothing.

Description

Method; sets the position of the control point of the edge. You must call shape.beginEdit() before using this method. See shape.beginEdit().

Example

The following example sets the beginning control point of the specified edge to the (0, 1) coordinates:

x = 0; y = 1; var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit(); shape.edges[0].setControl(0, x, y); shape.endEdit();

edge.splitEdge()

Availability

Flash MX 2004.

Usage

edge.splitEdge( t )

Parameters

t A floating-point value between 0 and 1 that specifies where to split the edge. A value of 0 represents one end point, and 1 the other. For example, passing a value of 0.5 splits the edge in the middle, which, for a line is exactly in the center. If the edge represents a curve, 0.5 represents the parametric middle of the curve.

Returns

Nothing.

Description

Method; splits the edge into two pieces. You must call shape.beginEdit() before using this method.

Example

The following example splits the specified edge in half:

var shape = fl.getDocumentDOM().selection[0]; shape.beginEdit() shape.edges[0].splitEdge( 0.5 ); shape.endEdit()

     < 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