(myDO) && (myDO.stage) && ( myDO.parent.removeChild(myDO) )
;)
Latcho
Keith H wrote:
Steven,
Maybe its just me but...
Just doing a Boolean check on DisplayObjects always put my scripts in
high risk of runtime errors.
Especially in the case of "cleanup" operations.
Sometimes I might have a function that attempts removing a
DisplayObject that has not been "added" to the stage or has already
been removed.
So I check if the "stage" property is null for almost all cases now.
var myDO:Sprite=new Sprite();
try {
//if (myDO) { //Creates runtime error
if (myDO && myDO.stage != null) {
myDO.parent.removeChild(myDO);
} } catch (e:Error) {
trace(e.message);
}
-- Keith H --
www.keith-hair.net
Steven Sacks wrote:
I don't understand why you would not want to write a single line of
code in the class where it would provide the most clarity, and
instead write MORE code in another class obscuring the behavior that
is going on. In other words, you're writing more code to write the
same code. You're going to write addChild either way, why make it
more complicated than it needs to be?
Always follow the KISS principle.
BTW, Ekameleon, you should use
if (target)
Instead of
if (target != null)
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders