Flash Builder - How to build or include an SWC
I'm trying to recre开发者_如何学Cate a modernized version of this tutorial here - but I'm having problems building and referencing a SWC file for inclusion in my Flash Builder project. Whenever I try to reference the SWC, Flash says it's "not a compile time constant" - can anyone help me with the process of building a SWC (mainly, naming it so that Flash Builder can reference it) - and then, in Flash Builder, creating that reference to the SWC? Thanks
To add a swc to Flash Builder, follow these steps:
You can build a swc from Flash Builder by creating a Library project as Emanuil also answered already. Normally, all classes that are in the source path of the library project will end up in the swc and those classes are then usable in another project that has the swc in its library path.
Another way of creating a swc is by using Flash, publishing not only to a swf but to a swc too (it's a checkbox in publish settings). Then all library items that have "Export for ActionScript" checked and a class name, will end up in the swc for use in another project.
You reference classes from the swc exactly the same as you would reference a class in your own source path:
// this should be the package and class name of the class you need:
// not the name of the swc it comes from!
import some.package.name.ClassFromSWC;
...
new ClassFromSWC();
Hope this helps...
To build a SWC file you need to create a Library Project. You can find detailed instructions in the "About library projects" article in the Flash Builder documentation.
To use a SWC file in a Flex Project, just copy it into the libs
folder of that project.
I don't know for Flash Builder, but in Flash Develop, you just have to right click on the swc file you want in the project files list panel, and click on "add to library".
Use Flex Library Project to create SWC like the comment above. There are many ways to include external code to your project.
_ Copy to libs folder since default build path included that folder.
_ Project Properties > Action script Build Path > Add SWC to add an SWC file which could locate anywhere in your file system.
_ Project Properties > Action script Build Path > Add Project to include your Flex Library Project, in case the project is under development, so that you don't need to export SWC file and copy it into your application project every time the library changes.
精彩评论