Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tea.display
- {
- import flash.display.Shape;
- import flash.display.Sprite;
- import flash.display.Stage;
- import flash.geom.Rectangle;
- /**
- *
- * Implementation of Bota's (ialmeida.com) "getPlaceHolder()".
- *
- * @param p_object Reference.
- * @param p_thickness Border thickness.
- * @param p_color Border color.
- *
- * @return A box with a "wireframe" based on reference dimension.
- *
- * @date 16/02/2011
- * @author Rafael Rinaldi (rafaelrinaldi.com)
- *
- * */
- public function getPlaceHolder( p_object : *, p_thickness : Number = 1, p_color : Number = 0xCC0000 ) : Sprite
- {
- var container : Sprite;
- var shape : Shape;
- var leftLine : Shape;
- var rightLine : Shape;
- var x : String = "x";
- var y : String = "y";
- var width : String = "width";
- var height : String = "height";
- var bounds : Rectangle;
- if(p_object is Stage) {
- width = "stageWidth";
- height = "stageHeight";
- }
- if(p_object is Rectangle) {
- bounds = p_object;
- } else {
- bounds = new Rectangle(
- p_object[x],
- p_object[y],
- p_object[width],
- p_object[height]
- );
- }
- container = new Sprite;
- shape = new Shape;
- shape.graphics.lineStyle(p_thickness, p_color);
- shape.graphics.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
- shape.graphics.endFill();
- leftLine = new Shape;
- leftLine.graphics.lineStyle(p_thickness, p_color);
- leftLine.graphics.moveTo(bounds.x + bounds.width, bounds.y + bounds.height);
- leftLine.graphics.lineTo(bounds.x, bounds.y);
- rightLine = new Shape;
- rightLine.graphics.lineStyle(p_thickness, p_color);
- rightLine.graphics.moveTo(bounds.x, bounds.y + bounds.height);
- rightLine.graphics.lineTo(bounds.x + bounds.width, bounds.y);
- container.addChild(shape);
- container.addChild(leftLine);
- container.addChild(rightLine);
- return container;
- }
- }
Add Comment
Please, Sign In to add comment