00:00
00:00
Newgrounds Background Image Theme

UmanaJose just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As3: Api. Shapes

2,138 Views | 4 Replies
New Topic Respond to this Topic

As3: Api. Shapes 2007-05-11 17:39:47


AS3:Main

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

Response to As3: Api. Shapes 2007-05-11 17:44:46


Wow, that's so simplifyed from AS2.0, that great. And you spelled circle sircle


BBS Signature

Response to As3: Api. Shapes 2007-05-11 17:46:55


Circle looks like a circle this time around.
From one of the other tuts - a triangle:
var triangle:Sprite = new Sprite();
with (triangle.graphics) {
lineStyle(1, 0x000000, 1);
beginFill(0x000000, 1);
moveTo(-10,10);
lineTo(10,10);
lineTo(0,-10);
lineTo(-10,10);
}
addChild(triangle);


.

BBS Signature

Response to As3: Api. Shapes 2007-05-11 18:45:17


At 5/11/07 05:46 PM, Pingo-Five wrote: Circle looks like a circle this time around.
From one of the other tuts - a triangle:

now that has little to nothing to do with this topic :S


<3

Response to As3: Api. Shapes 2007-05-12 05:48:20


for more info on the addChild, I sugest reading As3: Display List & Swapping Depths