1 /** 2 * com.sekati.draw.DrawUtils 3 * @version 2.0.1 4 * @author jason m horwitz | sekati.com 5 * Copyright (C) 2007 jason m horwitz, Sekat LLC. All Rights Reserved. 6 * Released under the MIT License: http://www.opensource.org/licenses/mit-license.php 7 */ 8 9 /** 10 * static class wrapper for various drawing and shape utilities 11 */ 12 class com.sekati.draw.DrawUtils { 13 /** 14 * draw a rectangle (various init options) 15 * @param target (MovieClip) target scope to create MovieClip within 16 * @param rName (String) name of rectangle mc to be created 17 * @param w (Number) rectangle width 18 * @param h (Number) rectangle height 19 * @param color (Number) rectangle hexadecimal color 20 * @param alpha (Number) rectangle alpha 21 * @param lineWeight (Number) rectangle line width 22 * @param lineColor (Number) rectangle line hexadecimal color 23 * @return Void 24 * 25 * {@code Usage: 26 * DrawUtils.drawRect (_root, "box", 320, 240, 0xff00ff, 75, 1, 0xffeeff); 27 * } 28 */ 29 public static function drawRect(target:MovieClip, rName:String, w:Number, h:Number, color:Number, alpha:Number, lineWeight:Number, lineColor:Number):Void { 30 var mc:MovieClip = target.createEmptyMovieClip( rName, target.getNextHighestDepth( ) ); 31 var c:Number = (color) ? color : 0xFFFFFF; 32 var a:Number = (alpha) ? alpha : 100; 33 var lw:Number = (lineWeight) ? lineWeight : 0; 34 var lc:Number = (lineColor) ? lineColor : 0xFF00FF; 35 mc.lineStyle( lw, lc, a ); 36 mc.beginFill( c, a ); 37 mc.moveTo( 0, 0 ); 38 mc.lineTo( w, 0 ); 39 mc.lineTo( w, h ); 40 mc.lineTo( 0, h ); 41 mc.endFill( ); 42 } 43 private function DrawUtils() { 44 } 45 }