Two objectives: distribute production tasks without including the “com” folder, and create a workflow for further development of the code library with a hard gate before release to production.

Code Library Distribution
The inspiration for these objectives came when the small company I work for contracted another firm in order to meet a deadline. We could not share the codebase, so they were producing content that they were unable to test. This led to some quality issues and prevented an effective way to close the loop on problems.Hopefully some other issues that never rose above the annoyance level could also be solved along the way. Such as contractors who had access to the library never updating it, and a lack of rigor promoting reusability since the entire library is constantly exposed to every project that uses it, and version control can’t prevent changes in the library from effecting multiple projects in unintended ways.

There are 2 parts to the solution I chose: using a compiled code resource (.swc file) and packaging it in a Flash Extension for distribution.

Creating a swc is detailed in Chapter 31 of Moock’s Essential ActionScript 3. A swc is a compiled MovieClip and  – placed in the correct location in the Flash Configuration folder – it will appear as a component in the Flash IDE.

The other part of the solution is a method to install the swc to the correct location in the Configuration folder. I anticipate that this will eliminate plaintive phonecalls from production at 2am. The way to do this is to set up the swc as a Flash Extension so that the Extension Manager can put it where it belongs.

Step-by-step (very specific to my implementation):

Create swc

  1. Create a folder named nsdk in My Documents folder
  2. Create folder structure of code library inside nsdk: com/novatekcom/display, com/novatekcom/objects, etc.
  3. Copy ResponsiveSprite.as into display folder from version control.
  4. Rename the original ResponsiveSprite.as so that it is no longer accessible to Flash via classpaths – this will ensure testing is accurate later on.
  5. Create a new ActionScript file in nsdk folder named nsdk.as.
  6. nsdk.as contains the following code:
    package{import com.novatekcom.*;
    import flash.display.Sprite;
    public class nsdk extends Sprite
    {
    com.novatekcom.display.ResponsiveSprite;
    }
    }
  7. Create nsdk.fla in Flash, and set the document class to nsdk
  8. In publish settings uncheck html and check export swc option.
  9. Publish – swc file will appear in nsdk folder.

Create MXP (Extension) file

  1. Copy Sample.mxi from C:\Program Files\Adobe\Adobe Extension Manager\Samples\Flash folder to nsdk folder
  2. Rename Sample.mxi to nsdk.mxi
  3. Open nsdk.mxi in a text editor (avoid using a hardcore xml editor though) such as flashDevelop or notepad.
  4. Change all the attributes in the document to match the particulars of what nsdk is. There is documentation on acceptable values for this document here.
  5. Open Extension Manager and select File->Package Extension…
  6. Navigate to nsdk.mxi in the nsdk folder and select it
  7. Extension Manager will prompt to save nsdk.mxp in the nsdk folder – OK
  8. Select File->Install Extension…
  9. Verify that extension installed in the current user’s Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\Components\nsdk
  10. Open test fla that will use code in nsdk component. Open components window and drag nsdk component from nsdk folder into the test file library. Put
    import com.novatekcom.display.ResponsiveSprite

    in the test fla’s document class and run it.

Post to Twitter