Intro:
Iv just bin messing around with AS3 now trying to figure stuff out. And then I stumbeld upon som cool functions. when drawing API in AS2 I had some problems figuring out how to make like a sircle. Well, in AS3 its really easy. it doesn't involve anny events or anny import or anything like that.
Circle:
myShape.graphics.drawCircle(x, y, radius);
x is the x position of the sircle, measured from the topp left corner of the shape.
y is the y position of the sircle, measured from the topp left corner of the shape.
radius is the radius of the sircle. a radius is the length from the middle of the sircle and out to the edge.
Ellipse:
myShape.graphics.drawEllipse(x, y,width,hight);
x is the x position of the sircle, measured from the topp left corner of the shape.
y is the y position of the sircle, measured from the topp left corner of the shape.
width is the width of the shape
hight is the hight of the shape
Square:
myShape.graphics.drawRect(x, y,width,hight);
x is the x position of the sircle, measured from the topp left corner of the shape.
y is the y position of the sircle, measured from the topp left corner of the shape.
width is the width of the shape
hight is the hight of the shape
RoundSquare:
myShape.graphics.drawRoundRect(x, y,width,hight,ellipseWidth,ellipseHight);
x is the x position of the sircle, measured from the topp left corner of the shape.
y is the y position of the sircle, measured from the topp left corner of the shape.
width is the width of the shape
hight is the hight of the shape
ellipseWidth this determines the shape of the corner horisontaly.
ellipseHight this determines the shape of the corner verticaly. this is optional.
Example:
var circle:Shape=new Shape();
// defines the new shape
circle.graphics.beginFill(0x483971, 1);
// tells flash that we want color in our shape, and what color. the 1 is the alpha. 1=100% .5=50% if you wan 100% you dont have to add it. it is 100 by default.
circle.graphics.drawCircle(0, 0, 50);
// draws the sircle
circle.graphics.endFill();
//stopp ading fill
this.addChild(circle);
//place the shape on the stage
all this is what I have found out by reading and testing, so it might not be 100% correct.
and I probobly have a lot of typing errors. but Im Norwegian and its getting late. =P
I hope this helps a lot of people, feel free to add what ever you like.
-phyconinja