Created
February 18, 2011 00:03
-
-
Save rafaelrinaldi/833009 to your computer and use it in GitHub Desktop.
Just align an object (anyone with x&y properties) based on a Point instance.
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.util | |
{ | |
import flash.geom.Point; | |
/** | |
* | |
* Just align an object (anyone with x&y properties) based on a Point instance. | |
* | |
* @param p_object Object to be aligned. | |
* @param p_point The Point instance. | |
* | |
* @return True if everything goes well, false otherwise. | |
* | |
* @example | |
* <code> | |
* import flash.display.Shape; | |
* import flash.geom.Point; | |
* | |
* import tea.util.place; | |
* | |
* var shape : Shape = new Shape; | |
* shape.graphics.beginFill(0x0); | |
* shape.graphics.drawRect(0, 0, 150, 150); | |
* shape.graphics.endFill(); | |
* | |
* place(shape, new Point(10, 20)); | |
* | |
* addChild(shape); | |
* </code> | |
* | |
* @date 17/02/2011 | |
* @author Rafael Rinaldi (rafaelrinaldi.com) | |
* | |
* */ | |
public function place( p_object : Object, p_point : Point ) : Boolean | |
{ | |
const x : String = "x"; | |
const y : String = "y"; | |
if(!p_object.hasOwnProperty(x) || !p_object.hasOwnProperty(y)) return false; | |
p_object[x] = p_point[x]; | |
p_object[y] = p_point[y]; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment