forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreateRectangleShape.as
More file actions
32 lines (28 loc) · 866 Bytes
/
createRectangleShape.as
File metadata and controls
32 lines (28 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package utils.draw
{
import flash.display.Graphics;
import flash.display.Shape;
/**
* Create a shape that is a simple solid color-filled rectangle
*
* @param width Width of the rectangle
* @param height Height of the rectangle
* @param color Color of the rectangle. Default is black.
* @param alpha Alpha of the rectangle. Default is full opacity.
* @param x Initial x position
* @param y Initial y position
* @return The created shape
* @author Jackson Dunstan, modified by Mims Wright
*/
public function createRectangleShape(width:uint, height:uint, color:uint = 0, alpha:Number = 1, x:Number = 0, y:Number = 0):Shape
{
var rect:Shape = new Shape();
var g:Graphics = rect.graphics;
g.beginFill(color, alpha);
g.drawRect(0, 0, width, height);
g.endFill();
rect.x = x;
rect.y = y;
return rect;
}
}