Sunday, June 7, 2009

Code package management in flash and eclipse

There was a time where I'd have a copy of a framework or as3 code package in the folder of every project I'd use it in. This wasn't a big deal, until I did a search one day and realized I had about nine copies of Tweener strewn about my harddrive - a situation ridiculous enough to merit change.

I created a folder named Flash Packages, and copied every bit of code I reuse (or even might) to it. In the flash IDE the change was simple enough - add this new folder to your list of classpaths. To get there you open Flash's preferences, navigate to the Actionscript panel, and - under the "Language" label - click on the button for Actionscript 2 or 3 respectively. This will alter the global classpath (affecting every flash document you create in the IDE). Settings for the document-level classpath can be found in the Publishing settings. Add your new created and sorted package folder to the list and you're done :)

What's more interesting, however, is the fact that you can add relative paths as well. There's a default entry of "." which causes every FLA to include any classes in it's own directory, while an entry of ".." would cause the directory's parent to be searched.

There are also a number of token/variable things you can use to represent certain important locations. If anyone knows of more, let me know:
  • $(AppConfig) - Flash CS3 configuration folder, which contains default Actionscript classes
  • $(LocalData) - Not exactly sure where this one points

My workflow includes both flash and the Eclipse editor, though, and for the longest time I couldn't figure out how to mirror this kind of change in it's environment. Just found out how to do it, though, and it's pretty easy. Just add a folder to your project (New>Folder), click the Advanced button, and set up the option for "Link To Folder In the File System" :) This is where you'll add packages from the folder of actionscript libraries you created earlier.

1 comment:

  1. good one!! very practical indeed - I have 7 tweener's and 4 papervision3d's in my projects folder alone.