Forum Topic: As3: Api. Shapes

(697 views • 4 replies)

This topic is 1 page long.

<< < > >>
None

phyconinja

Reply To Post Reply & Quote

Posted at: 5/11/07 05:39 PM

phyconinja EVIL LEVEL 25

Sign-Up: 09/18/04

Posts: 2,828

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


None

Coaly

Reply To Post Reply & Quote

Posted at: 5/11/07 05:44 PM

Coaly LIGHT LEVEL 23

Sign-Up: 08/11/04

Posts: 2,829

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

Zed's Dead

BBS Signature

None

Pingo-Five

Reply To Post Reply & Quote

Posted at: 5/11/07 05:46 PM

Pingo-Five NEUTRAL LEVEL 11

Sign-Up: 11/09/05

Posts: 347

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);


None

Cecemel

Reply To Post Reply & Quote

Posted at: 5/11/07 06:45 PM

Cecemel DARK LEVEL 16

Sign-Up: 08/19/05

Posts: 1,078

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


None

phyconinja

Reply To Post Reply & Quote

Posted at: 5/12/07 05:48 AM

phyconinja EVIL LEVEL 25

Sign-Up: 09/18/04

Posts: 2,828

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


All times are Eastern Standard Time (GMT -5) | Current Time: 12:14 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!