/ Published in: ActionScript 3
This function returns a Shape that can be used as a border around your Flash movie. It accepts a colour, width and an alpha.
Expand |
Embed | Plain Text
package { import flash.display.MovieClip; import flash.display.Shape; public class DrawBorder extends MovieClip { private var _border:Shape; private var _borderColour:uint = 0xFF0000; private var _borderWidth:uint = 2; private var _borderAlpha:Number = 0.3; public function DrawBorder():void { _border = new Shape(); _border = drawBorder(_borderColour, _borderWidth, _borderAlpha); addChild(_border); } private function drawBorder($borderColour:uint = 0x0000, $borderWidth:uint = 1, $borderAlpha:Number = 1):Shape { var border:Shape = new Shape(); border.graphics.beginFill($borderColour, $borderAlpha); border.graphics.drawRect($borderWidth, 0, stage.stageWidth-$borderWidth, $borderWidth); border.graphics.endFill(); border.graphics.beginFill($borderColour, $borderAlpha); border.graphics.drawRect(stage.stageWidth-$borderWidth, $borderWidth, $borderWidth, stage.stageHeight-$borderWidth); border.graphics.endFill(); border.graphics.beginFill($borderColour, $borderAlpha); border.graphics.drawRect(0, stage.stageHeight-$borderWidth, stage.stageWidth-$borderWidth, $borderWidth); border.graphics.endFill(); border.graphics.beginFill($borderColour, $borderAlpha); border.graphics.drawRect(0, 0, $borderWidth, stage.stageHeight-$borderWidth); border.graphics.endFill(); return border; } } }
Comments
Subscribe to comments
You need to login to post a comment.

I have now put this into a more concise static class which can be found here ... http://snipplr.com/view/46868/as3-drawpixelborderaroundstage-static-class/