MovieClip | +--com.robertpenner.display.DrawingClip
The DrawingClip class extends the MovieClip class adding advanced drawing utilities.
ActionScript 2.0; Flash Player 6
Property summary
Property | Description |
---|---|
xpen:Number |
The xpen property of the DrawingClip. |
ypen:Number |
The ypen property of the DrawingClip. |
xpenStart:Number |
The xpenStart property of the DrawingClip. |
ypenStart:Number |
The ypenStart property of the DrawingClip. |
Method summary
Method | Description |
---|---|
init() : Void |
Decorates all MovieClips with the methods of this class. |
mixin(obj:Object) : Void |
Decorates a particular MovieClip instance with the methods of this class. |
setXPen(x:Number) : Void |
Sets the x coordinate of the drawing pen. |
getXPen() : Number |
Returns the x coordinate of the drawing pen. |
setYPen(y:Number) : Void |
Sets the y coordinate of the drawing pen. |
getYPen() : Number |
Returns the y coordinate of the drawing pen. |
getXPenStart() : Number |
Returns the x coordinate of the point where a new subpath was started. |
getYPenStart() : Number |
Returns the y coordinate of the point where a new subpath was started. |
drawLine(x1:Number, y1:Number, x2:Number, y2:Number) : Void |
Draws a line between two points using the current line style. |
drawTri(p1:Object, p2:Object, p3:Object) : Void |
Draws a triangle defined by three corner points. |
drawQuad(p1:Object, p2:Object, p3:Object, p4:Object) : Void |
Draws a quadrilateral defined by four corner points. |
drawRect(x1:Number, y1:Number, x2:Number, y2:Number) : Void |
Draws a rectangle defined by two corner points. |
drawRectRel(x:Number, y:Number, w:Number, h:Number) : Void |
Draws a rectangle defined by relative coordinates, a starting point and a width and height. |
drawRectCent(x:Number, y:Number, w:Number, h:Number) : Void |
Draws a rectangle defined by a center point and a width and height. |
drawSquare(x:Number, y:Number, w:Number) : Void |
Draws a square defined by a starting point and a width. |
drawSquareCent(x:Number, y:Number, w:Number) : Void |
Draws a square defined by a center point and a width. |
drawDot(x:Number, y:Number) : Void |
Draws a one-pixel wide dot defined by a point. |
drawPoly(pts:Array) : Void |
Draws a polygon defined by a collection of points. |
drawRegPoly(x:Number, y:Number, r:Number, numPts:Number, rotation:Number) : Void |
Draws a regular polygon (a polygon with equal angles and sides). |
drawOval(x:Number, y:Number, rx:Number, ry:Number) : Void |
Draws an oval. |
drawCircle(x:Number, y:Number, r:Number) : Void |
Draws a circle. |
curveThruTo(pointX:Number, pointY:Number, anchorX:Number, anchorY:Number) : Void |
Draws a curve using the current line style from the current drawing position to (anchorX, anchorY) through the point that ((pointX, pointY) specifies. |
drawCurve3Pts(p1:Object, p2:Object, p3:Object) : Void |
Draws a curve using the current line style through the three specified points. |
drawBezier(anchorX1:Number, anchorY1:Number, controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX2:Number, anchorY2:Number, tolerance:Number) : Void |
Draws a cubic bezier curve using the current line style. |
drawBezierPts(anchorP1:Object, controlP1:Object, controlP2:Object, anchorP2:Object, tolerance:Number) : Void |
Draws a cubic bezier curve using the current line style. |
curveToCubic(controlX1:Number, controlY1:Number, controlX2:Number, controlY2:Number, anchorX:Number, anchorY:Number, tolerance:Number) : Void |
Draws a cubic bezier curve using the current line style from the current drawing position. |
curveToCubicPts(controlP1:Object, controlP2:Object, anchorP:Object, tolerance:Number) : Void |
Draws a cubic bezier curve using the current line style from the current drawing position. |
com.robertpenner.display.DrawingClip.init();
Nothing.
Decorates all MovieClips with the methods of this class.
com.robertpenner.display.DrawingClip.mixin(my_mc);
obj:Object
- The object to mix in.
Nothing.
Decorates a particular MovieClip instance with the methods of this class.
my_mc.setXPen(50);
x:Number
- The x coordinate of the drawing pen.
Nothing.
Sets the x coordinate of the drawing pen.
trace (my_mc.getXPen());
The x coordinate of the drawing pen.
Returns the x coordinate of the drawing pen.
my_mc.setYPen(50);
y:Number
- The y coordinate of the drawing pen.
Nothing.
Sets the y coordinate of the drawing pen.
trace (my_mc.getYPen());
The y coordinate of the drawing pen.
Returns the y coordinate of the drawing pen.
trace (my_mc.getXPenStart());
The x coordinate of the point where a new subpath was started.
Returns the x coordinate of the point where a new subpath was started.
trace (my_mc.getYPenStart());
The y coordinate of the point where a new subpath was started.
Returns the y coordinate of the point where a new subpath was started.
my_mc.lineStyle(4, 0x0000FF, 60);
my_mc.drawLine(0, 0, 50, 50);
x1:Number
- The x position of the first point.
y1:Number
- The y position of the first point.
x2:Number
- The x position of the second point.
y2:Number
- The y position of the second point.
Nothing.
Draws a line between two points using the current line style.
my_mc.lineStyle(4, 0x0000FF, 60);
var a:Object = {x:20, y:100};
var b:Object = {x:90, y:0};
var c:Object = {x:200, y:50};
my_mc.drawTri(a, b, c);
p1:Object
- The first corner point of the triangle.
p2:Object
- The second corner point of the triangle.
p3:Object
- The third corner point of the triangle.
Nothing.
Draws a triangle defined by three corner points.
my_mc.beginFill(0x00CC22, 40);
my_mc.lineStyle(2, 0x330000);
var a:Object = {x:0, y:20};
var b:Object = {x:10, y:80};
var c:Object = {x:100, y:120};
var d:Object = {x:150, y:0};
my_mc.drawQuad(a, b, c, d);
my_mc.endFill();
p1:Object
- The first corner point of the quadrilateral.
p2:Object
- The second corner point of the quadrilateral.
p3:Object
- The third corner point of the quadrilateral.
p4:Object
- The fourth corner point of the quadrilateral.
Nothing.
Draws a quadrilateral defined by four corner points.
my_mc.beginFill(0x33DD00, 60);
my_mc.drawRect(10, 10, 240, 150);
my_mc.endFill();
x1:Number
- The x position of the first corner point.
y1:Number
- The y position of the first corner point.
x2:Number
- The x position of the second corner point.
y2:Number
- The y position of the second corner point.
Nothing.
Draws a rectangle defined by two corner points.
my_mc.beginFill(0x0000FF, 40);
my_mc.drawRectRel(60, 60, 20, 30);
my_mc.endFill();
x:Number
- The x position of the starting point.
y:Number
- The y position of the starting point.
w:Number
- The width of the rectangle.
h:Number
- The height of the rectangle.
Nothing.
Draws a rectangle defined by relative coordinates, a starting point and a width and height.
my_mc.lineStyle(2, 0x00FF00);
my_mc.drawRectCent(150, 100, 70, 10);
x:Number
- The x position of the center point.
y:Number
- The y position of the center point.
w:Number
- The width of the rectangle.
h:Number
- The height of the rectangle.
Nothing.
Draws a rectangle defined by a center point and a width and height.
my_mc.lineStyle(2, 0x00FF00);
my_mc.drawSquare(250, 10, 50);
x:Number
- The x position of the starting point.
y:Number
- The y position of the starting point.
w:Number
- The width of the square.
Nothing.
Draws a square defined by a starting point and a width.
my_mc.lineStyle(2, 0x00FF00);
my_mc.drawSquare(250, 10, 50);
x:Number
- The x position of the center point.
y:Number
- The y position of the center point.
w:Number
- The width of the square.
Nothing.
Draws a square defined by a center point and a width.
my_mc.beginFill(0xFF0000);
my_mc.drawDot(130, 100);
my_mc.endFill();
x:Number
- The x position of the point.
y:Number
- The y position of the point.
Nothing.
Draws a one-pixel wide dot defined by a point.
var pts:Array = [];
var numPoints:Number = 50;
while (numPoints--) {
pts.push({x:Math.random()*300, y:Math.random()*300});
}
my_mc.beginFill(0x339933);
my_mc.drawPoly(pts);
my_mc.endFill();
pts:Array
- An array of point objects, each point containing x and y properties.
Nothing.
Draws a polygon defined by a collection of points.
my_mc.beginFill(0xFF0000, 70);
my_mc.drawRegPoly(100, 100, 90, 5, 15);
my_mc.endFill();
x:Number
- The x position of the center point.
y:Number
- The y position of the center point.
r:Number
- The radius from the center to one of the polygon's corners.
numPts:Number
- The number of points (and sides) of the polygon.
rotation:Number
- The angle (in degrees) to rotate the polygon.
Nothing.
Draws a regular polygon (a polygon with equal angles and sides).
my_mc.beginFill(0x0000FF, 40);
my_mc.drawOval(80, 100, 50, 75);
my_mc.endFill();
x:Number
- The x position of the center point.
y:Number
- The y position of the center point.
rx:Number
- The horizontal radius from the center to the edge of the oval.
ry:Number
- The vertical radius from the center to the edge of the oval.
Nothing.
Draws an oval.
my_mc.beginFill(0x0000FF, 40);
my_mc.drawCircle(150, 100, 50);
my_mc.endFill();
x:Number
- The x position of the center point.
y:Number
- The y position of the center point.
r:Number
- The radius from the center to the edge of the circle.
Nothing.
Draws a circle.
my_mc.lineStyle(4, 0x0000FF, 60);
my_mc.curveThruTo(400,50,100,200);
pointX:Number
- The x position of the curve-through point.
pointY:Number
- The y position of the curve-through point.
anchorX:Number
- The x position of the next anchor point.
anchorY:Number
- The y position of the next anchor point.
Nothing.
Draws a curve using the current line style from the current drawing position to (anchorX, anchorY) through the point that ((pointX, pointY) specifies.
this.onMouseMove = function() {
my_mc.clear();
my_mc.lineStyle(4, 0x0000FF, 60);
my_mc.drawCurve3Pts({x:100, y:100}, {x:my_mc._xmouse, y:my_mc._ymouse}, {x:400, y:400});
}
p1:Object
- The first point of the curve.
p2:Object
- The middle point of the curve.
p3:Object
- The third point of the curve.
Nothing.
Draws a curve using the current line style through the three specified points.
my_mc.lineStyle(4, 0xFF0000, 70);
my_mc.drawBezier(0, 0, 100, 0, 0, 100, 200, 200, 2);
anchorX1:Number
- The x position of the first anchor point.
anchorY1:Number
- The y position of the first anchor point.
controlX1:Number
- The x position of the first control point.
controlY1:Number
- The y position of the first control point.
controlX2:Number
- The x position of the second control point.
controlY2:Number
- The y position of the second control point.
anchorX2:Number
- The x position of the second anchor point.
anchorY2:Number
- The y position of the second anchor point.
tolerance:Number
- The accuracy of the curve. The smaller the tolerance, the more accurate and complex the curve.
Nothing.
Draws a cubic bezier curve using the current line style.
my_mc.lineStyle(4, 0xFF0000, 70);
var a:Object = {x:100, y:20};
var b:Object = {x:0, y:80};
var c:Object = {x:150, y:100};
var d:Object = {x:10, y:200};
my_mc.drawBezierPts(a, b, c, d, 2);
anchorP1:Object
- The first anchor point.
controlP1:Object
- The first control point.
controlP2:Object
- The second control point.
anchorP2:Object
- The second anchor point.
tolerance:Number
- The accuracy of the curve. The smaller the tolerance, the more accurate and complex the curve.
Nothing.
Draws a cubic bezier curve using the current line style.
my_mc.lineStyle(2, 0x33DD77);
my_mc.moveTo(60, 40);
my_mc.curveToCubic(100, 0, 0, 100, 250, 30, 2);
controlX1:Number
- The x position of the first control point.
controlY1:Number
- The y position of the first control point.
controlX2:Number
- The x position of the second control point.
controlY2:Number
- The y position of the second control point.
anchorX:Number
- The x position of the next anchor point.
anchorY:Number
- The y position of the next anchor point.
tolerance:Number
- The accuracy of the curve. The smaller the tolerance, the more accurate and complex the curve.
Nothing.
Draws a cubic bezier curve using the current line style from the current drawing position.
my_mc.lineStyle(4, 0x0000FF, 60);
my_mc.moveTo(60, 20);
var a:Object = {x:20, y:100};
var b:Object = {x:90, y:0};
var c:Object = {x:200, y:50};
my_mc.curveToCubicPts(a, b, c);
controlP1:Object
- The first control point.
controlP2:Object
- The second control point.
anchorP:Object
- The next anchor point.
tolerance:Number
- The accuracy of the curve. The smaller the tolerance, the more accurate and complex the curve.
Nothing.
Draws a cubic bezier curve using the current line style from the current drawing position.
trace (my_mc.xpen);
The xpen property of the DrawingClip.
trace (my_mc.ypen);
The ypen property of the DrawingClip.
trace (my_mc.xpenStart);
The xpenStart property of the DrawingClip.
trace (my_mc.ypenStart);
The ypenStart property of the DrawingClip.