Posted By

adrianparr on 12/16/10


Tagged

template box api Drawing as3 cross placeholder linestyle moveto lineto


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

burnandbass


AS3 Draw a Placeholder Cross-Box inside Sprite or MovieClip


 / Published in: ActionScript 3
 

This function is handy if you need to draw placeholder graphic inside a sprite or movieclip.

  1. function drawCrossBox($sprite:Sprite, $width:int=100, $height:int=100, $x:int=0, $y:int=0, $bgColor:uint=0xFFFFFF, $bgAlpha:Number=1, $lineThickness:Number=1, $lineColor:uint=0x000000, $lineAlpha:Number=1):void
  2. {
  3. $sprite.graphics.beginFill($bgColor, $bgAlpha);
  4. $sprite.graphics.drawRect($x, $y, $width, $height);
  5. $sprite.graphics.endFill();
  6.  
  7. $sprite.graphics.lineStyle($lineThickness, $lineColor, $lineAlpha);
  8. $sprite.graphics.moveTo($x,$y);
  9. $sprite.graphics.lineTo($x+$width, $y);
  10. $sprite.graphics.lineTo($x+$width, $y+$height);
  11. $sprite.graphics.lineTo($x, $y+$height);
  12. $sprite.graphics.lineTo($x, $y);
  13. $sprite.graphics.lineTo($x+$width, $y+$height);
  14. $sprite.graphics.moveTo($x+$width, $y);
  15. $sprite.graphics.lineTo($x, $y+$height);
  16. }
  17.  
  18. var _mySprite:Sprite = new Sprite();
  19. drawCrossBox(_mySprite, 240, 320, 0, 0, 0xCCCCCC, 1, 1, 0x000000, 1);
  20. addChild(_mySprite);

Report this snippet  

You need to login to post a comment.