Guest User

Untitled

a guest
Jul 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package tea.display
  2. {
  3.  
  4. import flash.display.Shape;
  5. import flash.display.Sprite;
  6. import flash.display.Stage;
  7. import flash.geom.Rectangle;
  8.  
  9. /**
  10. *
  11. * Implementation of Bota's (ialmeida.com) "getPlaceHolder()".
  12. *
  13. * @param p_object Reference.
  14. * @param p_thickness Border thickness.
  15. * @param p_color Border color.
  16. *
  17. * @return A box with a "wireframe" based on reference dimension.
  18. *
  19. * @date 16/02/2011
  20. * @author Rafael Rinaldi (rafaelrinaldi.com)
  21. *
  22. * */
  23.  
  24. public function getPlaceHolder( p_object : *, p_thickness : Number = 1, p_color : Number = 0xCC0000 ) : Sprite
  25. {
  26. var container : Sprite;
  27.  
  28. var shape : Shape;
  29. var leftLine : Shape;
  30. var rightLine : Shape;
  31.  
  32. var x : String = "x";
  33. var y : String = "y";
  34. var width : String = "width";
  35. var height : String = "height";
  36.  
  37. var bounds : Rectangle;
  38.  
  39. if(p_object is Stage) {
  40. width = "stageWidth";
  41. height = "stageHeight";
  42. }
  43.  
  44. if(p_object is Rectangle) {
  45. bounds = p_object;
  46. } else {
  47. bounds = new Rectangle(
  48. p_object[x],
  49. p_object[y],
  50. p_object[width],
  51. p_object[height]
  52. );
  53. }
  54.  
  55. container = new Sprite;
  56.  
  57. shape = new Shape;
  58. shape.graphics.lineStyle(p_thickness, p_color);
  59. shape.graphics.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
  60. shape.graphics.endFill();
  61.  
  62. leftLine = new Shape;
  63. leftLine.graphics.lineStyle(p_thickness, p_color);
  64. leftLine.graphics.moveTo(bounds.x + bounds.width, bounds.y + bounds.height);
  65. leftLine.graphics.lineTo(bounds.x, bounds.y);
  66.  
  67. rightLine = new Shape;
  68. rightLine.graphics.lineStyle(p_thickness, p_color);
  69. rightLine.graphics.moveTo(bounds.x, bounds.y + bounds.height);
  70. rightLine.graphics.lineTo(bounds.x + bounds.width, bounds.y);
  71.  
  72. container.addChild(shape);
  73. container.addChild(leftLine);
  74. container.addChild(rightLine);
  75.  
  76. return container;
  77. }
  78.  
  79. }
Add Comment
Please, Sign In to add comment