PDA

View Full Version : How do I fetch a Movieclips Instance name?


verklighet
10-25-2010, 10:00 AM
Hey guys!

Is there a way to fetch the instance name of a movieclip with actionscript, and then apply that name to get a specific movieclip, instead of writing the movieclips name?

For example, a line like this;

Object(this.parent).clip3_mc.filters = ;

Is there a way to fetch the instance name like this;

Object(this.parent).[B]clip+grabInstancename+_mc.filters = [blur];

(where the bold letters are replaced with the proper terms)

I hope the question isn't too confusing.
I have this movieclip that I'd like to use multiple times and instead of making separate movieclips with the same actionscript copied into them, I'd rather use the unique instance names that they have.

Trying to be more convenient and practical I guess.

Thanks in advance guys!

senocular
10-25-2010, 12:08 PM
Use array access. It replace the form object.property with object["property"]. Because the property name is presented as a string, you can dynamically create it yourself

Object(this.parent)["clip"+grabInstancename+"_mc"].filters = [blur];

Instance names themselves, by the way, can be obtained through the .name property.

verklighet
10-25-2010, 09:32 PM
Excellent!

Thx Senocular, it worked perfectly.

Cool seeing you're in SF also :) Enjoying the rainy season?

Thx again!

senocular
10-26-2010, 12:17 PM
Cool seeing you're in SF also :) Enjoying the rainy season?

Not especially. I always complain when there is no rain. Then, when it finally does rain, all I do is complain about that. ; )