< Day Day Up > |
Availability Flash MX 2004. Description The Path object defines a sequence of line segments (straight, curved, or both), which you typically use when creating extensible tools. The following example shows an instance of a Path object being returned from the flash object: path = fl.drawingLayer.newPath(); See also the drawingLayer object. Method summary for the Path objectThe following methods are available for the Path object:
Property summary for the Path objectThe following properties are available for the Path object:
path.addCubicCurve()Availability Flash MX 2004. Usage path.addCubicCurve(xAnchor, yAnchor, x2, y2, x3, y3, x4, y4) Parameters xAnchor A floating-point number that specifies the x position of the first control point. yAnchor A floating-point number that specifies the y position of the first control point. x2 A floating-point number that specifies the x position of the second control point. y2 A floating-point number that specifies the y position of the second control point. x3 A floating-point number that specifies the x position of the third control point. y3 A floating-point number that specifies the y position of the third control point. x4 A floating-point number that specifies the x position of the fourth control point. y4 A floating-point number that specifies the y position of the fourth control point. Returns Nothing. Description Method; appends a cubic Bézier curve segment to the path. Example The following example creates a new path, stores it in the myPath variable, and assigns the curve to the path: var myPath = fl.drawingLayer.newPath(); myPath.addCubicCurve(0, 0, 10, 20, 20, 20, 30, 0); path.addCurve()Availability Flash MX 2004. Usage path.addCurve(xAnchor, yAnchor, x2, y2, x3, y3) Parameters xAnchor A floating-point value that specifies the x position of the first control point. yAnchor A floating-point value that specifies the y position of the first control point. x2 A floating-point value that specifies the x position of the second control point. y2 A floating-point value that specifies the y position of the second control point. x3 A floating-point value that specifies the x position of the third control point. y3 A floating-point value that specifies the y position of the third control point. Returns Nothing. Description Method; appends a quadratic Bézier segment to the path. Example The following example creates a new path, stores it in the myPath variable, and assigns the curve to the path: var myPath = fl.drawingLayer.newPath(); myPath.addCurve(0, 0, 10, 20, 20, 0); path.addPoint()Availability Flash MX 2004. Usage path.addPoint(x, y) Parameters x A floating-point value that specifies the x position of the point. y A floating-point value that specifies the y position of the point. Returns Nothing. Description Method; adds a point to the path. Example The following example creates a new path, stores it in the myPath variable, and assigns the new point to the path: var myPath = fl.drawingLayer.newPath(); myPath.addPoint(10, 100); path.clear()Availability Flash MX 2004. Usage path.clear() Parameters None. Returns Nothing. Description Method; removes all points from the path. Example The following example removes all points from a path stored in the myPath variable: var myPath = fl.drawingLayer.newPath(); myPath.clear(); path.close()Availability Flash MX 2004. Usage path.close() Parameters None. Returns Nothing. Description Method; appends a point at the location of the first point of the path and extends the path to that point, which closes the path. If the path has no points, no points are added. Example The following example creates a closed path: var myPath = fl.drawingLayer.newPath(); myPath.close(); path.makeShape()Availability Flash MX 2004. Usage path.makeShape([bSupressFill [, bSupressStroke]]) Parameters bSuppressFill A Boolean value that, if set to true, suppresses the fill that would be applied to the shape. The default value is false. This parameter is optional. bSupressStroke A Boolean value that, if set to true, suppresses the stroke that would be applied to the shape. The default value is false. This parameter is optional. Returns Nothing. Description Method; creates a shape on the Stage by using the current stroke and fill settings. The path is cleared after the shape is created. This method has two optional parameters for suppressing the fill and stroke of the resulting shape object. If you omit these parameters or set them to false, the current values for fill and stroke are used. Example The following example creates a shape with the current fill and no stroke: var myPath = fl.drawingLayer.newPath(); myPath.makeShape(false, true); path.newContour()Availability Flash MX 2004. Usage path.newContour() Parameters None. Returns Nothing. Description Method; starts a new contour in the path. Example The following example creates a hollow square: var myPath = fl.drawingLayer.newPath(); myPath.addPoint( 0, 0); myPath.addPoint( 0, 30); myPath.addPoint(30, 30); myPath.addPoint(30, 0); myPath.addPoint( 0, 0); myPath.newContour(); myPath.addPoint(10, 10); myPath.addPoint(10, 20); myPath.addPoint(20, 20); myPath.addPoint(20, 10); myPath.addPoint(10, 10); myPath.makeShape(); path.nPtsAvailability Flash MX 2004. Usage path.nPts Description Read-only property; an integer representing the number of points in the path. A new path has 0 points. Example The following example uses the Output panel to show the number of points in the path referenced by the myPath variable: var myPath = fl.drawingLayer.newPath(); var numOfPoints = myPath.nPts; fl.trace("Number of points in the path: " + numOfPoints); // Displays: Number of points in the path: 0 |
< Day Day Up > |