Draw Dotted lInes in Flash ( FOUND )


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // Feel free to use this code in any way you see fit
  2. // www.warmforestflash.com
  3.  
  4. package com.warmforestflash.drawing
  5. {
  6. import flash.display.Shape;
  7. import flash.display.BitmapData;
  8. import flash.geom.Rectangle;
  9.  
  10. public class DottedLine extends Shape
  11. {
  12. private var _w:Number;
  13. private var _h:Number;
  14. private var _color:uint;
  15. private var _dotAlpha:Number;
  16. private var _dotWidth:Number;
  17. private var _spacing:Number;
  18.  
  19. //============================================================================================================================
  20. public function DottedLine(w:Number = 100, h:Number = 1, color:uint = 0x777777, dotAlpha = 1, dotWidth:Number = 1, spacing:Number = 1)
  21. //============================================================================================================================
  22. {
  23. _w = w;
  24. _h = h;
  25. _color = color;
  26. this.alpha = dotAlpha;
  27. _dotWidth = dotWidth;
  28. _spacing = spacing;
  29. drawDottedLine();
  30. }
  31.  
  32. //============================================================================================================================
  33. private function drawDottedLine():void
  34. //============================================================================================================================
  35. {
  36. graphics.clear();
  37. var tile:BitmapData = new BitmapData(_dotWidth + _spacing, _h + 1, true);
  38. var r1:Rectangle = new Rectangle(0, 0, _dotWidth, _h);
  39. var argb:uint = returnARGB(_color, 255);
  40. tile.fillRect(r1, argb);
  41. var r2:Rectangle = new Rectangle(_dotWidth, 0, _dotWidth + _spacing, _h);
  42. tile.fillRect(r2, 0x00000000);
  43. graphics.beginBitmapFill(tile, null, true);
  44. graphics.drawRect(0, 0, _w, _h);
  45. graphics.endFill();
  46. }
  47.  
  48. //============================================================================================================================
  49. private function returnARGB(rgb:uint, newAlpha:uint):uint
  50. //============================================================================================================================
  51. {
  52. var argb:uint = 0;
  53. argb += (newAlpha<<24);
  54. argb += (rgb);
  55. return argb;
  56. }
  57.  
  58. }
  59. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.