Each developer has a favourite IDE that he or she swears by. I’m an Eclipse man myself. However, during a project I worked on recently, I had the misfortune of diving back into development using Flash CS3, a tool that, despite it’s widespread use, I have managed to mostly stay away from since it’s release. Why? Flash CS3 is a BAD tool for ActionScript development*. Needless to say I was a bit rusty with the Flash authoring tool, but I was nonetheless determined to create a nice, clean, object-oriented, design-patterny product.
*Perhaps I shall elaborate on this statement in a later post
The first thing I did was create some MovieClip symbols. I created, for example, a custom button containing a background (to which i gave the instance name “bg”) and a text field (called “label”). I then opened the properties for this button and included a path to a class (com.foo.MyButton) that would be associated with the symbol. In the class, I declared the two child MovieClips as variables like so.
package com.foo {
import flash.display.*;
import flash.text.*;
class MyButton extends MovieClip {
public var bg:Sprite;
public var label:TextField;
}
}
However, when I ran this code it seemed to choke on the two variable declarations.

Error 1151: Has this ever happened to you? How embarrassing!
I was stumped. Was Flash CS3 actually unable to deal with this situation? Many people I asked seemed to think so. Eventually, I talked to someone who knew the solution.

Sarah Plowright of ActionScriptGirl.com had this advice:
Remember how if you place a MovieClip on the stage or in another MovieClip in an AS2 project you had to also declare a variable of the same name if you’re using a custom class? Well, in Flash CS3 / AS3, Adobe has decided to give us developers some options. The only problem is, they didn’t exactly make these options obvious to the user. If you didn’t know about this change, you be getting all sorts of nasty errors and wondering why you ever decided to build that project using Flash instead of Flex.
If you’re getting errors along the lines of "1151: A conflict exists with definition myMC in namespace internal." and you’re working custom classes attached to library objects with instances, the error is probably caused by the fact that you have “Automatically declare stage instances” checked. This checkbox is located under Publish Settings > Flash > ActionScript 3.0 Settings. If it’s checked, Flash will automatically add variables to your class at compile time. If you already have tried to declare a variable in your class for this instance, the compiler will throw error 1151, as you will now have two declarations of the same variable. If it’s unchecked, you will have to declare a public variable for every onstage instance that you want access to in ActionScript. Remember, you must make your instance declarations public, or they won’t work!

Make sure that "Automatically declare stage instances" is unchecked.
The fix is easy, simply decide whether or not you want Flash to create your variable names for you. I personally prefer to declare my own stage instances as I believe it’s a better practice to have all your variables listed at the top of a class, but annoyingly, this means I will have to uncheck the “Automatically declare stage instances” checkbox for every new FLA file. Unfortunately, this option only seems to be available under publish settings, and not available under the global application preferences.
Here are some sample files that show’s how this all works.
accessingMovieClipsExample
I happen to agree with Sarah that the best way to work is to uncheck the checkbox and declare all of your variables yourself. This is the only way that really enforces good practices when you are using classes behind your MovieClips in the library.
Thanks for the help, Sarah!