Created
February 18, 2011 13:33
-
-
Save rafaelrinaldi/833653 to your computer and use it in GitHub Desktop.
Implementation of Bota's (ialmeida.com) "getPlaceHolder()".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment