Getting Named Parameters for a Component in Flash using JSFL

When working with components, using JSFL, you can get access to the selected Component using

fl.getDocumentDOM().selection[0]

If your component has parameters, you should be able to access each parameter’s name attribute, but for some reason, there’s a bug in Flash. You can still get the parameters, but it takes a little doing.
The following script will return an array of parameters for the selected component.

var attribs:Array = MMExecute("var a = [];" +
	"for(var i  in fl.getDocumentDOM().selection[0].parameters){" +
	"	a.push(i);" +
	"}" +
	"a.splice(a.length/2).join(',')").split(",");

How does it work?
When you use the for…in feature on the parameters array, it returns double the results that it should, given the length attribute. For example, if you were to say

for(var i = 0; i< fl.getDocumentDOM().selection[0].parameters.length; i++)

you might get 11 results, whereas with this:

for(var i  in fl.getDocumentDOM().selection[0].parameters)

you'd get 22, the same results, followed by a list of names. It's as though there's another named value array tacked on to the results of the for...in. I've used this to produce a double length array, which I then chop off half and return a joined String.
We then parse this string back into an array and can move through it.

Creating a swc from Flex

I spent a bit of time looking for a decent answer to this and only found it halfway in a video. Here we go:
To make a swc from a flex file

  1. Prepare your files
  2. Make a new Flex Library Project with the name you desire for your swc
  3. Copy your files into the src directory, maintaining directory structure where applicable
  4. In the Flex Library Build Path settings for the Library Project select the src directory
  5. Right click the project and select “Build Project”

Your swc will appear in the bin directory.