flash drawing API 101

1. Always first call Shape.graphics.clear() before you really draw anything. Here.

2. If you want your drawings to show up, besides adding your Shape/Sprite, etc object to the display list, you would need to specify either the lineStyle (by calling graphics.lineStyle(thinckness:Number=null, color:unit=0. alpha:Number=null, etc);)or the fillColor (by calling graphics.beginFill(color:uint, alpha:Number=null))or both before you draw anything, _after_ you did #1. For lineStyle, you will at least specify the thinkness; for fill, the color, both are the first parameter of the associated drawing function calls:

//draw a stroke in rectangle, without fill
var _rect1:Shape = new Shape();
_rect1.graphics.clear();
_rect1.graphics.lineStyle(1);
_rect1.graphics.drawRect(300,50, 200, 200);
addChild(_rect1);

//draw a solid rectangle, without stroke
var _rect2:Shape = new Shape();
_rect2.graphics.clear();
_rect2.graphics.beginFill(0);
_rect2.graphics.drawRect(300,50, 200, 200);
_rect2.graphics.endFill();
addChild(_rect1);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: