Code Hinting for SWCÂ’s in PrimalScript (Unity Client Classes Example)

Recently I started playing with Unity, a great XML Socket server product. One of UnityÂ’s cool features is it provides you with a bunch of AS2 classes that you can use to build pretty complex application. These classes are provided as a SWC that you include in your flaÂ’s library.

When I sat down initially to write some code, I didnÂ’t get any code hinting in my favorite editor PrimalScript since the classes were distributed in an SWC. SWCÂ’s are just zip files which contain a bunch of files that support the component. The majority of the SWCÂ’s contents are .asi files which provide interfaces and class information to the compiler for type checking. They are very similar to regular classes except they donÂ’t include any of the implementation, only the interface of each class.

PrimalScript includes support for ASI files so, with little effort, you can get full code hinting for SWCÂ’s.

Steps Required

  1. Obtain the SWC you are interested in, in this example I am using version 2.0.1 of the UClient classes as they are well written and are a good example of when such a technique is very useful. If you are running an older version, you may be interested in download the latest version from or if you own a licensed copy of Unity, you would use the SWC provided with the licensed version.
  2. Unzip the file you just downloaded, and location the SWC we are interested in which is located in UClient_2.0.1_Trial\UClient_2.0.1_Trial\lib\components
  3. Unzip the SWC to a temporary directory which you will delete at the end. This usually requires changing the extension of the swc from .swc to .zip.
  4. Copy all .asi files to a location where you would like to store them permanently. I usually place them in their own folder under the projects folder of my PrimalScript installation (on my machine it would be C:\Program Files\SAPIEN\PrimalScript\Projects\UClientClasses).
  5. Open PrimalScript.
  6. Select File > New > Project > ActionScript > New Project From Existing Folder.
  7. Set a name for your project, in this example I used “UClient Classes”.
  8. Set the Location field to the path of the folder we created in step 4.
  9. Click on OK.
  10. Now you can delete the directory created in step 2–the temporary directory containing the unzipped contents of the SWC.

ThatÂ’s it–you now have a project that contains all the .asi files. This project can be included in other workspaces (workspace can contain multiple projects). Once it is included in other workspaces, you will receive code hinting for the UClient classes even though you donÂ’t have the source code.

I usually keep several projects like this handy. It helps me keep my applicationÂ’s code separated from other libraries that I might have downloaded/obtained.

Note: There was an issue with interfaces not being recognized by PrimalScript in an earlier beta. If you have not upgraded your version of PrimalScript recently I reccomend that you do.

In case anyone wants to use the Unity client project and skip the above steps, you can download it here.

This entry was posted in Uncategorized by chafic. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>