Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created February 18, 2011 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrinaldi/833009 to your computer and use it in GitHub Desktop.
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.
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