drawingLayer object

 < Day Day Up > 

Availability

Flash MX 2004.

Description

The drawingLayer object is accessible from JavaScript as a child of the flash object. The drawingLayer object is used for extensible tools when the user wants to temporarily draw while dragging for example, when creating a selection marquee. You should call drawingLayer.beginFrame() before you call any other drawingLayer methods.

Method summary for the drawingLayer object

The following methods are available for the drawingLayer object:

Methods

Description

drawingLayer.beginDraw()

Puts Flash in drawing mode.

drawingLayer.beginFrame()

Erases what was previously drawn using the drawingLayer and prepares for more drawing commands.

drawingLayer.cubicCurveTo()

Draws a cubic curve from the current pen location using the parameters as the coordinates of the cubic segment.

drawingLayer.curveTo()

Draws a quadratic curve segment starting at the current drawing position and ending at a specified point.

drawingLayer.drawPath()

Draws the specified path.

drawingLayer.endDraw()

Exits drawing mode.

drawingLayer.endFrame()

Signals the end of a group of drawing commands.

drawingLayer.lineTo()

Draws a line from the current drawing position to the point (x,y).

drawingLayer.moveTo()

Sets the current drawing position.

drawingLayer.newPath()

Returns a new Path object.

drawingLayer.setColor()

Sets the color of subsequently drawn data.


drawingLayer.beginDraw()

Availability

Flash MX 2004.

Usage

drawingLayer.beginDraw([persistentDraw])

Parameters

persistentDraw A Boolean value (optional). If set to TRue, it indicates that the drawing in the last frame remains on the Stage until a new beginDraw() or beginFrame() call is made.(In this context, frame refers to where you start and end drawing; it does not refer to timeline frames.) For example, when users draw a rectangle, they can preview the outline of the shape while dragging the mouse. If you want that preview shape to remain after the user releases the mouse button, set persistentDraw to TRue.

Returns

Nothing.

Description

Method; puts Flash in drawing mode. Drawing mode is used for temporary drawing while the mouse button is pressed. You typically use this method only when creating extensible tools.

Example

The following example puts Flash in drawing mode:

fl.drawingLayer.beginDraw();

drawingLayer.beginFrame()

Availability

Flash MX 2004.

Usage

drawingLayer.beginFrame()

Parameters

None.

Returns

Nothing.

Description

Method; erases what was previously drawn using the drawingLayer and prepares for more drawing commands. Should be called after drawingLayer.beginDraw(). Everything drawn between drawingLayer.beginFrame() and an drawingLayer.endFrame() remains on the Stage until you call the next beginFrame() and endFrame(). (In this context, frame refers to where you start and end drawing; it does not refer to timeline frames.) You typically use this method only when creating extensible tools. See drawingLayer.beginDraw().

drawingLayer.cubicCurveTo()

Availability

Flash MX 2004.

Usage

drawingLayer.cubicCurveTo(x1Ctrl, y1Ctrl, x2Ctl, y2Ctl, xEnd, yEnd)

Parameters

x1Ctl A floating-point value that is the x location of the first control point.

y1Ctl A floating-point value that is the y location of the first control point.

x2Ctl A floating-point value that is the x position of the middle control point.

y2Ctl A floating-point value that is the y position of the middle control point.

xEnd A floating-point value that is the x position of the end control point.

yEnd A floating-point value that is the y position of the end control point.

Returns

Nothing.

Description

Method; draws a cubic curve from the current pen location using the parameters as the coordinates of the cubic segment. You typically use this method only when creating extensible tools.

Example

The following example draws a cubic curve using the specified control points:

fl.drawingLayer.cubicCurveTo(0, 0, 1, 1, 2, 0);

drawingLayer.curveTo()

Availability

Flash MX 2004.

Usage

drawingLayer.curveTo(xCtl, yCtl, xEnd, yEnd)

Parameters

xCtl A floating-point value that is the x position of the control point.

yCtl A floating-point value that is the y position of the control point.

xEnd A floating-point value that is the x position of the end control point.

yEnd A floating-point value that is the y position of the end control point.

Returns

Nothing.

Description

Method; draws a quadratic curve segment starting at the current drawing position and ending at a specified point. You typically use this method only when creating extensible tools.

Example

The following example draws a quadratic curve using the specified control points:

fl.drawingLayer.curveTo(0, 0, 2, 0);

drawingLayer.drawPath()

Availability

Flash MX 2004.

Usage

drawingLayer.drawPath(path)

Parameters

path A Path object to draw.

Returns

Nothing.

Description

Method; draws the path specified by the path parameter. You typically use this method only when creating extensible tools.

Example

The following example draws a path specified by the Path object named gamePath:

fl.drawingLayer.drawPath(gamePath);

drawingLayer.endDraw()

Availability

Flash MX 2004.

Usage

drawingLayer.endDraw()

Parameters

None.

Returns

Nothing.

Description

Method; exits drawing mode. Drawing mode is used when you want to temporarily draw while the mouse button is pressed. You typically use this method only when creating extensible tools.

Example

The following example exits drawing mode:

fl.drawingLayer.endDraw();

drawingLayer.endFrame()

Availability

Flash MX 2004.

Usage

drawingLayer.endFrame()

Parameters

None.

Returns

Nothing.

Description

Method; signals the end of a group of drawing commands. A group of drawing commands refers to everything drawn between drawingLayer.beginFrame() and drawingLayer.endFrame(). The next call to drawingLayer.beginFrame() will erase whatever was drawn in this group of drawing commands. You typically use this method only when creating extensible tools.

drawingLayer.lineTo()

Availability

Flash MX 2004.

Usage

drawingLayer.lineTo(x, y)

Parameters

x A floating-point value that is the x coordinate of the end point of the line to draw.

y A floating-point value that is the y coordinate of the end point of the line to draw.

Returns

Nothing.

Description

Method; draws a line from the current drawing position to the point (x,y). You typically use this method only when creating extensible tools.

Example

The following example draws a line from the current drawing position to the point (20,30):

fl.drawingLayer.lineTo(20, 30);

drawingLayer.moveTo()

Availability

Flash MX 2004.

Usage

drawingLayer.moveTo(x, y)

Parameters

x A floating-point value that specifies the x coordinate of the position at which to start drawing.

y A floating-point value that specifies the y coordinate of the position at which to start drawing.

Returns

Nothing.

Description

Method; sets the current drawing position. You typically use this method only when creating extensible tools.

Example

The following example sets the current drawing position at the point (10,15):

fl.drawingLayer.moveTo(10, 15);

drawingLayer.newPath()

Availability

Flash MX 2004.

Usage

drawingLayer.newPath()

Parameters

None.

Returns

A Path object.

Description

Method; returns a new Path object. You typically use this method only when creating extensible tools. See Path object.

Example

The following example returns a new Path object:

fl.drawingLayer.newPath();

drawingLayer.setColor()

Availability

Flash MX 2004.

Usage

drawingLayer.setColor(color)

Parameters

color The color of subsequently drawn data, in one of the following formats:

  • A string in the format "#RRGGBB" or "#RRGGBBAA"

  • A hexadecimal number in the format 0xRRGGBB

  • An integer that represents the decimal equivalent of a hexadecimal number

Returns

Nothing.

Description

Method; sets the color of subsequently drawn data. Applies only to persistent data. To use this method, the parameter passed to drawingLayer.beginDraw() must be set to true. You typically use this method only when creating extensible tools. See drawingLayer.beginDraw().

Example

The following example draws a red line on the Stage:

fl.drawingLayer.beginDraw( true ); fl.drawingLayer.beginFrame(); fl.drawingLayer.setColor( "#ff0000" ); fl.drawingLayer.moveTo(0,0); fl.drawingLayer.lineTo(100,100); fl.drawingLayer.endFrame(); fl.drawingLayer.endDraw();

     < 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