Graphics 类包含一组可用来创建矢量形状的方法。支持绘制的显示对象包括 Sprite 和 Shape 对象。这些类中的每一个类都包括
API地址:
http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html
graphics
属性,该属性是一个 Graphics 对象。以下是为便于使用而提供的一些辅助函数:drawRect()
、drawRoundRect()
、drawCircle()
和 drawEllipse()
。
无法通过 ActionScript 代码直接创建 Graphics 对象。如果调用 new Graphics()
,则会引发异常。
清除绘制到此 Graphics 对象的图形,并重置填充和线条样式设置。
|
例子:
this.graphics.clear();
//填充背景
this.graphics.beginFill(0xFFFFFF);
this.graphics.drawRect(0, 0, this.width, this.height);
this.graphics.endFill();
this.graphics.lineStyle(1, 0xBBBBBB);
//画横线
this.graphics.moveTo(0, grapWidth * i);
this.graphics.lineTo(this.width, grapWidth * i);
this.graphics.drawCircle(endX, endY, radio);
指定一种简单的单一颜色填充,在绘制时该填充将在随后对其它 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。
|
绘制一个圆。
|
绘制一个矩形。
|
对从上一次调用 beginFill()、beginGradientFill() 或 beginBitmapFill() 方法之后添加的直线和曲线应用填充。
|
lineStyle(thickness:
Number = NaN, color:
uint = 0, alpha:
Number = 1.0, pixelHinting:
Boolean = false, scaleMode:
String = "normal", caps:
String = null, joints:
String = null, miterLimit:
Number = 3):
void
指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。
|
将当前绘画位置移动到 (x, y)。
|
使用当前线条样式绘制一条从当前绘画位置开始到 (x, y) 结束的直线;当前绘画位置随后会设置为 (x, y)。
|