PDA

View Full Version : Checking if a movie clip exists.


Toby
03-11-2005, 09:04 AM
Just a quick one, but I cant seem to figure it out or find anything on it (Its probably so simple).

How do you check to see if a movieclip exists on the stage?

My code is quite simple:

on (rollOut) {
if("MOVIE CLIP EXISTS") {
attachMovie("off-artists", "mcOff", this.getNextHighestDepth());
mcOff._y = -60;
mcOff._x = -41;
}
}

What should i replace 'Movie Clip exists' with in terms of actionscript?

Cheers!

Toby

MD68
03-11-2005, 09:31 AM
if(typeof(ref_to_movie_clip) == "movieclip") {
etc...

or you could just check a property of the movie clip to see if it's 'undefined' eg.

if(ref_to_movie_clip._visible == undefined) {
then it probably isn't there...

Hope that's ok

Barn
03-12-2005, 06:48 AM
Actually, if you're certain that a particular instance name is not possibly a variable (idealing using a naming convention that alerts you to the data type without having to check), simply (path optional if the movieclip is in the same timeline as the code of the conditional):

if (_root.mvcClipName){
// Do whatever if clip exists;
};

Toby
03-13-2005, 12:34 PM
Actually, if you're certain that a particular instance name is not possibly a variable (idealing using a naming convention that alerts you to the data type without having to check), simply (path optional if the movieclip is in the same timeline as the code of the conditional):

if (_root.mvcClipName){
// Do whatever if clip exists;
};

Worked perfectly! Thanks alot!

Barn
03-13-2005, 10:09 PM
You're welcome.