Skip to content

Instantly share code, notes, and snippets.

@caubry
Last active December 12, 2015 02:28
Show Gist options
  • Save caubry/4698460 to your computer and use it in GitHub Desktop.
Save caubry/4698460 to your computer and use it in GitHub Desktop.
// emptyMovieClip as a MovieClip - x & y at 0
// Rectangle( x, y, width, height )
var currentRect:Rectangle = new Rectangle( 0, 0, 50, 50 );
var mc:MovieClip = emptyMovieClip.createEmptyMovieClip("mc", emptyMovieClip.getNextHighestDepth());
drawRectangle( mc, currentRect.x, currentRect.y, currentRect.width, currentRect.height, 0x000000, 100, 1, 0x000000, 100 );
private function drawRectangle(mc:MovieClip, rectX:Number, rectY:Number, rectWidth:Number, rectHeight:Number, fillColor:Number, fillAlpha:Number, lineThickness:Number, lineColor:Number, lineAlpha:Number)
{
mc.clear();
with (mc)
{
beginFill(fillColor, fillAlpha);
lineStyle(lineThickness, lineColor, lineAlpha);
moveTo(rectX, rectY);
lineTo(rectX, rectY + rectHeight);
lineTo(rectX + rectWidth, rectY + rectHeight);
lineTo(rectX + rectWidth, rectY);
endFill();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment