-
Senior Member
If MovieClip exists
Quite a simple question this one. I'm trying to prevent code being called on a DisplayObject if it doesn't exit.
This throws up an error
Code:
if (mc)
{
trace(mc);
}
Throws up the following error
1120: Access of undefined property mc.
I've tried if(mc.stage), if (contains(mc)) and if (this.getChildByName("mc")) and none of them seem to work
Using Flash PLayer 9 in CS6
Thanks
-
.
Hi,
You at least need to declare mc if it is not already on the stage, or it will throw an error like the one you have.
PHP Code:
var mc:MovieClip;
if (mc)
{
trace(mc);
}
else
{
trace("mc not on stage");
}
-
Senior Member
That worked, thanks
Strange, I don't remember this being an issue before. Perhaps I was thinking in AS2
Originally Posted by fruitbeard
Hi,
You at least need to declare mc if it is not already on the stage, or it will throw an error like the one you have.
PHP Code:
var mc:MovieClip;
if (mc)
{
trace(mc);
}
else
{
trace("mc not on stage");
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|