Vectors in AS3 are created by using the Graphics Class. Unlike the majority of other classes, there is no need to create an instance of this class before you use it because an instance of it is already instantiated as a property of any display objects that is a Shape, Sprite, and MovieClip.
You can draw simple geometric objects like lines, circles, triangles or squares defining every property, complex drawings defining lines and create more complex effect with a Matrix.
Typical process:
circle.graphics.beginFill (0xFF66FF, 0.8) ;
circle | . | graphics |
. | beginFill | (0xFF66FF | , | 0,8) | ; |
instance | . | class |
. | method name | hex color | , | alpha (0 to 1) | ; |
circle.graphics.drawCircle(0,2,20) ;
circle | . | graphics |
. | beginFill | (0 | , | 2 | , | 20 ) | ; |
instance | . | class |
. | method name | center: x value | , | center: y value | , | radius value | ; |
Circle.graphics.endFill();
circle | . | graphics |
. | endFill | ( ) | ; |
instance | . | class |
. | method name | () | ; |
addChild (circle);
beginBitmapFill ( bitmap: Bitmapdata, matrix: Matrix, repeat: Boolean=true, smooth: Boolean=false) :void
Fills a drawing area with a bitmap image.
Bitmapdata | A transparent or opaque bitmap image that contains bits to be displayed | |
Matrix | (default=null) A matrix object (of the flash.geom.Matrix.class), which you can use to define transformations to the bitmap. | matrix= new flash.geom. Matrix (); matrix.rotate(Math.PI/4); |
repeat: Boolean | (default=true) If true, the bitmap image repeats in a tiled pattern. If false the bitmap does not repeat and the edges of the bitmap are used for any fill area that extends beyond the bitmap. |
|
smoth: Boolean | (default=flase) If false upscaled bitmap images are rendered using the NEAREST-NEIGHBOR algorithm and look pixelated. if tue, upsaled bitmap images are rendered using a BILINEAR algorith, it will look better but it runs slower. |
canvas.graphics.beginBitmapFill( source, matrix, true, false );
canvas.graphics.drawRect( -cx, -cy, sw, sh );
canvas.graphics.endFill();
beginFill ( color: uint, alpha: Number =1) : void
Specifies a simple one-color fill. Use with other graphic methods (like lineTo() or drawCircle()) for drawing.
beginGradientFill ( shader: Shader, colors: Array, ratios: Array, matrix: Matrix, spreadMethod:String ="pad", ________interpolationMethod: String ="rgb", focalPointRatio:Number =0):void
Speciefies a gradient fill. It needs subsequent calls to drawing methods to create an object.
drawCircle( x: Number, y: Number , radius: Number) : void
drawEllipse( x: Number, y: Number , width: Number, height: Number) :void
drawRoundRect( x: Number, y: Number , height: Number, ellipseWidth: Number , ellipseHeight: Number =NaN)
drawTriangles( vertices: Vector. <Number>, indices: Vector.<int>=null, uvData: Vecor. <Number> = null, culling: String = "none") :void
endFill( ) :void
Applies a fill to the lines and curves that were added since the last call to the beginFill(), BeginGradientFill(), or beginBitmapFill() method.
The basic graphics methods for drawing vectors are:
lineStyle() - Specificies the look of any line stroke we make.
lineStyle (thickness =n, color =n, alpha =0.8, pixelHinting ="false", scaleMode = "normal", caps ="none", joints ="bevel" , miterLimit = 3)
moveTo() - Moves the drawing pointer to the specific point.
moveTo ( x = n, y =n )
lineTo() - Draws a line to the specified point.
lineTo ( x = n, y =n )
curveTo() - Draws a curve to the specific point.
beingFill() - Starts color filling the area between the lines.
endFill() - Ends of the fill of the area between the lines.
clear() - Clears all vectors inside a graphics object.
Advanced beginBitmapFil :
http://www.reflektions.com/miniml/template_permalink.asp?id=328
http://www.reflektions.com/miniml/template_permalink.asp?id=327
Using a matrix:
http://www.kirupa.com/forum/showthread.php?288157-Problems-with-beginBitmapFill