Listening Has Always Been Our Strongest Tool!

Just Give Us a Try, we respond to all messages within 1 business day. Really!


How can we reach out to you?






NDA From The Start
We keep your idea safe. We're always willing to sign a Non-Disclosure Agreement with you and fully protect your intellectual property.

captcha

Other Ways To Meet Us :info@zealousys.com
Our Blog
Nov 28
2013

How to Create SWC ActionScript Libraries

By zealousys

What’s a SWC?

SWC’s are like SWF’s in that incorporates all your compiled ActionScript, CSS, assets. They are a lot like a zip or rar to keep a folder of things together. They differ from a SWF in that they are meant for compile time use, Flash or Flex can use the contents inside a SWC without having to have the original source files.

It uses many SWC’s behind the scene that correspond to what Flash player target you’ve requested. Like playerglobal.swc, contains all the interfaces to the functions built in to the player, flex.swc has all the flex related code you link against when you import anything from mx.

Why need to use SWC?

Everybody needs to have those files. The team needs it when working with you on shared code, but probably don’t want or can’t deal with source control to get them, or maybe they shouldn’t have access to your code at all, just be able to use it. Like if you’re just hired a contractor to help out do the animations on that game, they just want enough to be getting it to build, and very well may have no clue about SVN/CVS. A single zip of only what’s needed locked in time is best, and that’s what a SWC can be.

Two types of way to create a SWC Libraries

1. Generating through Flash CS3 and CS4

Here are the steps to generate a partial package SWC:

  • Create an FLA to make a SWC and generate a full SWC of the entire package you wish to generate as a SWC. Don’t worry about file size or excess files, this file are for reference.
  • Take the SWC and place it next to that same FLA (CS3) or in publish setting specify the SWC as an external library (CS4). Now, go back to your class package. Save a backup copy first, and then in the package folder, erase all of the classes you’d like to EXCLUDE from the SWC library.
  • Generate another SWC (give it a different name). If you did this right, this new SWC will only contain the classes you have left in the package folder. Since the Flash compiler prioritizes class path over SWC files, the compiler found the source for those files in the right place, so it placed them in the new SWC. When it got to one it couldn’t find, it then searched your external library SWC’s, in this case the one holding the whole package and said ‘yes, here it is, it compiles. Since it is an external library though, it doesn’t pull the class into the new SWC. As result, a partial package SWC and SWF library, containing only the .as files you explicitly wanted contained inside.

2. Using Flash Builder

  • 1. Select File > New > Flex Library Project.
  • 2. Enter a Project name, and then specify the following:

Project Location

The default location is the current workspace.

On Windows platforms, the default workspace location is C:\Documents and Settings\Flex Developer\Adobe Flash Builder\.
On the Macintosh, the default workspace location is /Users/Flex Developer/Adobe Flash Builder/. You can choose a different project location by deselecting the Use Default Location option.

Flex SDK Version
Choose default or specific. You can also click the Configure SDKs link to add, edit, or remove SDKs on the main Preferences page.

Include Adobe AIR libraries

Select this option if your library must use AIR features, such as access to the AIR APIs. Flash Builder then changes the library path of this new Flex Library project so that it includes airglobal.swc and airframework.swc. Web-based Flex projects cannot use this library.
Do not select this option if you are writing a generic library intended to be used only in a web-based Flex application, or in either a web-based or AIR-based application.

  • 3. Click Next.
  • 4. (Optional) Set the build path information. For example, you can add folders to the project’s source path that contains the components to include in the SWC file. You can also add other projects, folder, or library SWC files to include in your library project. See Using SWC files in your projects.
  • 5. When you finish entering the project settings, click Finish.
View My Stats