10-16-2008
Textmate: Publishing Flash Files
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"
Thanks for this, unfortunately it no longer works with the new project panel in CS4
thanks for reminding me, I have updated the post. I haven’t looked too much into the API documentation that Grant Skinner has provided, but this can still be done with a little work.
Although it doesn’t exactly do what you’ve written above – namely recognise flp’s – my <a href=’http://github.com/simongregory/flash.tmbundle’>Flash bundle</a> for TextMate is designed to help working with the Flash IDE and TextMate. If you didn’t already know about it I hope it’s of some interest.