Flash Tutorial: How to Import MovieClips into a Flash Builder ActionScript Project
Firstly, in the Flash IDE, create your asset and save it as a MovieClip. I'm using a character from an upcoming game called "Tooth'n'Claw" that I'm going to release soon through Actionsprite.
Next you need to open up the properties window for your MovieClip where we will give it a Linkage ID that will allow Flash Builder to identify the Movieclip.
In the properties window, check both "Export for ActionScript" and "Export in frame 1" - you should see that the Class value is automatically filled out by Flash - it's the same name as you've given the MovieClip. You can change this to whatever you want, but remember it because it will be the name you use to refer to the MovieClip in Flash Builder.
Now that your MovieClip is prepared, go to "File>Publish Settings" and click on the "Flash" Tab. On this screen you want to make sure "Export SWC" is selected.
Now publish your file (I've named mine "Assets.Fla") and you'll notice that a .SWC file of the same name has been created. This file contains all of the assets that you have selected for export and is the file that you will use in Flash Builder to gain access to them.
Now you can load up Flash Builder and create a new project. You'll see there are various types of projects you can create, but the one we are going to deal with is an ActionScript project seeing as this is the whole point of the tutorial.
Give your new project a name, and then click the "Next" button.
Now this is where you tell Flash Builder about the .SWC file you created. Choose the "Library Path" tab and click on the "Add SWC" button.
A dialog will appear with a "Browse" button. Click this and point Flash Builder to the Assets.SWC file you made previously.
Now that you've located your .SWC file, you should be able to view its contents via the Package Explorer window.
Once opened, you should see the Package Explorer window open to the side of your layout. Open up the "Referenced Libraries" section. Drilling down, you should be able to see the MovieClip you named in the properties window back in Flash. In this Case its called "ninja_cat" and has a little "c" icon next to it (for "class").
Finally, in the code window you can write your ActionScript as you normally would. This is where you'll start to see some of the benefits of working in Flash Builder. As a coding environment there are a lot of little touches that make your life easier--some of which are incorporated into the Flash IDE, but for some reason, not all. Firstly you'll notice that when you create a new Actionscript project, Flash Builder will automatically create a Document Class for you and fill some of it for you automatically. Create a new instance of your library item as you usually would and attach it to the stage. Flash Builder should be smart enough to realize that it needs to import the MovieClip Class as well, which it will do for you automatically--see, I told you it was good.
Finally "Run" your movie and you'll see the MovieClip has been successfully imported and added to your stage. From here on in you should be able to import and use items as you need to. If you need to add more assets, or update existing assets, simply republish a new .SWC from Flash.
So that's all there is to it. I will
try and cover some more aspects of Flash Builder in future articles.