This works for me:
-----------------------------
var myObject:Object;
if (myObject) {
removeChild(myObject);
}
-------------------------------
Another method would be to catch the error:
-----------------------------
try {
removeChild(myObject);
} catch (e:Error) {
//do nothing
}
------------------------------
Or you can compare it to "null":
------------------------------
if (myObject != null) {
removeChild(myObject);
}
------------------------------
Sunil
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Michael
Trim
Sent: 19 July 2007 13:58
To: [email protected]
Subject: [Flashcoders] Object Detection AS3
Hi Flashcoders,
Learning AS3 in the deep end at the moment, so excuse the questions if
too newb for this list.
In AS2 I may have done something like the following.
_1___________________________________
if(myObject){
myObject.removeMovieClip();
}
this.attachMovie("MyObject","myObject",1);
_____________________________________
What would similar code look like in AS3? As
_2____________________________________
removeChild(myObject);
_____________________________________
fails if myObject doesn't exist yet as does
_3___________________________________
if(myObject)
_____________________________________
Which I don't think you can do anyway?
It's the last one I'm really interested in, how do you detect if
something exists?
Thanks
Michael
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com