Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created October 4, 2010 22:01
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/610534 to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/610534 to your computer and use it in GitHub Desktop.
Replace one display object for another one.
package rinaldi.display
{
/**
*
* Replace one display object for another one.
*
* @param p_scope Scope of the items.
* @param p_oldObject Object to be replaced.
* @param p_newObject New object to replace the old object.
* @return The new object placed.
*
* @see rinaldi.display
*
* @date 30/09/2010
* @author Rafael Rinaldi (rafaelrinaldi.com)
*
*/
public function replace( p_scope : Object, p_oldObject : Object, p_newObject : Object ) : Object
{
if(p_oldObject != null && p_scope["contains"](p_oldObject)) {
p_scope["removeChild"](p_oldObject);
p_oldObject = null;
}
if(p_newObject == null) return null;
return p_scope["addChild"](p_newObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment