SWC assets packer is Sh/php script (compatible mac, linux) which compress a directory of assets (sound, image, data) into one swc file. The final swc file will contain assets packaged the same way you organized your folder (eg. myAsset/myFolder/happypic.png will become class myfolder.HappypicPng).
No need of using flash authoring tool to export your assets this script makes your assets integration quicker and more efficient.
How using it
Download files here and drop it in your scripts folder. Edit swc-assets-packer.sh and define SDK_LOCATION var with your flex sdk path (see below).
#!/bin/bash #enter you flex sdk location here SDK_LOCATION="/Users/gillesboisson/Development/SDK/flex_sdk_4.1.0.16076"; while getopts "p:s:f:" o do ...
In terminal tape:
sh myScriptDir/swc-assets-packer "myAssetDir" "NameOfMyPack"
It will create a swc called “NameOfMyPack.swc” with assets in “myAssetDir” inside your current directory.
Two optionals parameters are available:
-p allows you to move swc in a particular directory
sh myScriptDir/swc-assets-packer -p "myAssetLibDirectory" "myAssetDir" "NameOfMyPack"
-s allow you to create a swf in a particular directory
sh myScriptDir/swc-assets-packer -s "deploy/assets/" -p "myAssetLibDirectory" "myAssetDir" "NameOfMyPack" #compile NameOfMyPack.swf into deploy/assets/
How it works
First the sh script call a php script which scroll your assets folder and create automatically packages and to empty classes based on your assets organisation. For instance assetsDir/myDir/mySubDir/myImage.png will become the class mydir.mysubdor.MyImagePng.
All classes created are instancied in an empty classes declared inside a hidden package (called Z_ASSET_PACKER_YouPackageName), all theses classed are instancied in a class in root package called “YouPackageName”. This is the only way to force flash compiling all your assets.
After that the original sh script use the compc command to compile the main classe we created before and create a fresh new swc file.
optimization and automation
The sh script has been made for my workflow and it doesn’t perfectly with other cases, up to you to update the sh file in order to make your own batch.
For windows guys, you can easily create a batch script which will call the php script and flex sdk command (compc).
Hope this will save you some precious time, please fill free to drop comment if you have any question.
