Created
October 4, 2010 22:01
-
-
Save rafaelrinaldi/610534 to your computer and use it in GitHub Desktop.
Replace one display object for another one.
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 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