So if you're like me, you've probably been toying around with Macrodobia's
Flash 9 AS 3.0 Preview. And if you're like me, you're trying to figure out how you are going to migrate from ActionScript 2.0 to 3.0. There is a
migration guide that gives some clues to where things are headed, but to be honest, it isn't much help when it comes to learning how to really make the change.
One of the first problems I ran into with F9 Preview is the lack of attachMovie. If you check out that previously mentioned migration guide, it conveniently tells us that this method has been replaced with addChild. Right. So the question becomes: How do I work with assets in the library? The answer (at least as of yet) is fairly simple, if you're familiar with Object-Oriented Programming (which you should be, considering upcoming changes in 3.0) In fact, you may have used similar methods in your library from Flash 8 or before.
So what do you do with your MovieClip in the library? You assign a class to it. Let me show you how.
For example, if I had a MovieClip named mcMenu in my library, with all of it's children MovieClips and assets, I would right-click on mcMenu and select "Linkage." After that, just like before, we select "Export for ActionScript." Notice that now we don't have the option of choosing a linkage ID (identifier) for this MovieClip. We have to specify which class it's using. So all you have to do is make a simple class in the same directory with that name (mcMenu.as) and add some placeholders for your assets. By placeholders, I mean that if you had "mcButton" in your meMenu MovieClip, in your class you would declare the "public var mcButton:MovieClip." That's it. Now when your movie is compiled, you can add a child of mcMenu to your stage.
Here's how you could do that (this would go on the first frame of your movie):
var myMC:MovieClip = new mcMenu;
this.addChild(myMC);
//now you can access that child mc
myMC.mcButton.width *= 2;
There you go!