A while ago Lee Brimelow posted about a way to publish flash files from textmate, but for some reason it never worked for me. Based on that method and some research into extending flash I have created a way to test your flash movies from Textmate, without switching to Flash.

To do this I went to Bundles>Bundle Editor>Edit Commands. once there create a new command in the ActionScript 3 bundle by clicking on the + menu at the bottom left. I titled mine “Test in Flash” and the rest should go as follows:
Save: All Files in Project
Command(s):

echo "
fl.saveAll();
if(fl.getProject())
{
	if(fl.getProject().canTestProject())
	{
		fl.getProject().testProject();
	}
}
else
{
	if(fl.documents.length > 0)
	{
		fl.getDocumentDOM().testMovie();
	}
	else
	{
		alert('There Are No Open Documents');
	}
}" > /tmp/fc.jsfl
open /tmp/fc.jsfl -a "/Applications/Adobe Flash CS3/Adobe Flash CS3.app"

Input: None
Output: Discard
Activation: Key Equivalent, ichose to use cmd + ctrl + return
Scope Selector:

This will save all open fla files, if there is an open flp project it will test the project, if not it will check to make sure a file is open and test it or it will give you an alert telling you there are no open documents.

I have found that this doesn’t always work in Tiger, but works like a charm in Leopard.

UPDATE
The new Project Panel in CS4 is not compatible with the above code, and I haven’t looked into the API that Grant Skinner has released to allow this. here is the code for using Flash CS4 and publishing a single file:

echo "
fl.saveAll();
if(fl.documents.length > 0)
{
	fl.getDocumentDOM().testMovie();
}
else
{
	alert('There Are No Open Documents');
}" > /tmp/fc.jsfl
open /tmp/fc.jsfl -a "/Applications/Adobe Flash CS4/Adobe Flash CS4.app"