A project I've inherited includes a piece of code that sends a MovieClip to a frame with a specific label (in my case the label was 'disabledframe'). Unfortunately some of the MovieClips that extend this base class do not contain said frame label which resulted in a runtime error.
To make matters worse I do not have access to the original assets and adding the rame was therefore not an option. I knew that I could work around this problem by checking if the frame label exists, but couldn't remember how it was done...

Thanks to the power of Twitter and its awesome inhabitants I had the answer delivered within seconds - special thanks to @stray_and_ruby, @stevecarpenter (although his response time to my tweet was at least 24 seconds slower than the first correct answer, he needs to work on that ;-) and an anonymous commenter by the name of DaveW who pointed out a major error in the initial code I posted - oops.

view plain
1// assuming you have a movie clip named 'mc' with a label named 'blah'
2trace(movieClipHasLabel(mc, "blah")); // traces true
4function movieClipHasLabel(movieClip:MovieClip, labelName:String):Boolean {
5 var i:int;
6 var k:int = movieClip.currentLabels.length;
7 for (i; i < k; ++i) {
8 var label:FrameLabel = movieClip.currentLabels[i];
9 if (label.name == labelName)
10 return true;
11 }
12 return false;
Easy when you know that mc.currentLabels returns an Array of framelabel objects within that MovieClip.

By the way - since we are talking about Twitter - if you enjoy my blog posts then why not follow me?