PDA

View Full Version : Detecting if a movie clip is on stage


ICD2k3
02-08-2008, 06:06 PM
Hey guys,
In as2 I would detect if a movie clip was on the stage by something like this:

if(mc.getDepth() != undefined) { // remove movie clip }

however, i can't do this in as3. How do you detect if a movie clip is on the stage or not?

stompwampa
02-08-2008, 06:36 PM
Well, a down and dirty way to do it would be to detect if the movie clip's x/y coordinates are on within the stages boundaries, and then take your action based on that result.

dr_zeus
02-08-2008, 07:36 PM
If the MovieClip is not on stage, it's stage property will be null.

if(mc.stage)
{
//on stage
}
else
{
//not on stage
}

Dail
02-08-2008, 08:57 PM
You can also detect its addition and removal from the stage using the ADDED_TO_STAGE and REMOVED_FROM_STAGE events.

cancerinform
02-09-2008, 01:49 AM
trace(stage.contains(mc));