1
8
9 import com.sekati.except.IllegalArgumentException;
10
11
14 class com.sekati.draw.Polygon {
15
16
31 public static function draw(mc:MovieClip, points:Array, fillColor:Number, fillAlpha:Number, strokeWeight:Number, strokeColor:Number, strokeAlpha:Number):Void {
32 var sw:Number = (!strokeWeight) ? undefined : strokeWeight;
33 var sc:Number = (isNaN( strokeColor )) ? 0x000000 : strokeColor;
34 var sa:Number = (isNaN( strokeAlpha )) ? 100 : strokeAlpha;
35 var fa:Number = (isNaN( fillAlpha )) ? 100 : fillAlpha;
36
37 if (points.length < 3) {
38 throw new IllegalArgumentException( Polygon, "@@@ com.sekati.draw.Polygon.draw() Error: method requires a points array argument containing at least 3 Point objects.", arguments );
39 }
40
41 mc.clear( );
42 mc.lineStyle( sw, sc, sa, true, "none", "square", "miter", 1.414 );
43 if (!isNaN( fillColor )) {
44 mc.beginFill( fillColor, fa );
45 }
46 mc.moveTo( points[0].x, points[0].y );
47 var len:Number = points.length;
48 for(var i:Number = 0; i < len ; i++) {
49 mc.lineTo( points[i].x, points[i].y );
50 }
51 mc.lineTo( points[0].x, points[0].y );
52 if (!isNaN( fillColor )) {
53 mc.endFill( );
54 }
55 }
56 }
57