Posted By

adrianparr on 01/10/11


Tagged

pixel border draw as3 stage edge


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

mitien
kure69
pepperpunk


AS3 DrawPixelBorderAroundStage Static Class


 / Published in: ActionScript 3
 

This static class can be used to draw a coloured border around the edge of your SWF.

  1. package com.adrianparr.utils
  2. {
  3. import flash.display.Stage;
  4. import flash.display.Shape;
  5.  
  6. public class DrawPixelBorderAroundStage
  7. {
  8.  
  9. public static function draw($stage:Stage, $colour:uint, $width:uint, $alpha:Number):Shape
  10. {
  11. var border:Shape = new Shape();
  12. border.graphics.beginFill($colour, $alpha);
  13. border.graphics.drawRect($width, 0, $stage.stageWidth-$width, $width);
  14. border.graphics.drawRect($stage.stageWidth-$width, $width, $width, $stage.stageHeight-$width);
  15. border.graphics.drawRect(0, $stage.stageHeight-$width, $stage.stageWidth-$width, $width);
  16. border.graphics.drawRect(0, 0, $width, $stage.stageHeight-$width);
  17. border.graphics.endFill();
  18. return border;
  19. }
  20.  
  21. }
  22.  
  23. }
  24.  
  25. // Usage example
  26. //
  27. // import com.adrianparr.utils.DrawPixelBorderAroundStage;
  28. // private var _border:Shape;
  29. // _border = DrawPixelBorderAroundStage.draw(stage, 0x036CB4, 1, 1);
  30. // addChild(_border);

Report this snippet  

You need to login to post a comment.