Skip to content

Instantly share code, notes, and snippets.

@chrisyour
Created November 4, 2010 17:15
Show Gist options
  • Save chrisyour/662796 to your computer and use it in GitHub Desktop.
Save chrisyour/662796 to your computer and use it in GitHub Desktop.
Flash CS4/CS5 Project Panel: "Test Project" Keyboard Shortcut
// # I've assumed you've downloaded and installed the Flash CS4/CS5 Project Panel update at: http://www.gskinner.com/blog/archives/2010/07/project_panel_u.html
// # 1. Create this file in: /Users/{you}/Library/Application Support/Adobe/Flash CS4/en/Configuration/Commands
// # 2. Then go to Flash => Keyboard Shortcuts...
// # 3. Create your shortcut under the Commands menu, I use 'Cmd+Opt+P'
function call_method(p_panelName, p_function, p_param){
l = fl.swfPanels.length;
if (l == 0) return 'false';
for (i=0; i<l; i++){
if (fl.swfPanels[i].name == p_panelName) return (p_param == null) ? fl.swfPanels[i].call(p_function) : fl.swfPanels[i].call(p_function, p_param);
}
return 'false';
}
call_method('gProject', 'runCompileList');
@lestat1124
Copy link

Hmm. Interesting. I added the to the beginning of the jsfl file and now it saves all of the .fla files that are in the project but leaves the .as unsaved. Does the code look specifically for .fla files only. It doesn't seem that way to me unless Flash doesnt recognize .as scripts as fl.documents.

@chrisyour
Copy link
Author

Yes, it looks like fl.documents only targets .fla files. Not really all that handy, is it?

You can find Adobe's extending Flash CS4 documentation online at: http://help.adobe.com/en_US/Flash/10.0_ExtendingFlash/WS5b3ccc516d4fbf351e63e3d118a9024f3f-7ffa.html

CS5 docs are at: http://help.adobe.com/en_US/flash/cs/extend/index.html

Let me know if you find a solution and I'll add it to the Gist to help other people who come across this post.

Thanks,
Chris

@lestat1124
Copy link

Great. Will Do! Chris Thanks for your time, it's appreciated.

@chrisyour
Copy link
Author

No problem. Glad this gist was useful.

Chris

@lestat1124
Copy link

Well for now I have just went with a catch all because it seems Flash doesn't give you the ability to catch all open scripts into an array like the fl.documents and then save each individual one. Placing fl.saveAll() after the method call but before fl.openDocument lets Flash prompt you to save any open documents which haven't been saved yet. So a couple extra clicks but it's all worth it. Thanks alot. Here is what the code looks like now.

// # I've assumed you've downloaded and installed the Flash CS4/CS5 Project Panel update at: http://www.gskinner.com/blog/archives/2010/07/project_panel_u.html

// # 1. Create this file in: /Users/{you}/Library/Application Support/Adobe/Flash CS4/en/Configuration/Commands
// # 2. Then go to Flash => Keyboard Shortcuts...
// # 3. Create your shortcut under the Commands menu, I use 'Cmd+Opt+P'

function call_method(p_panelName, p_function, p_param){

// # Save all open documents before testing project - Stat1124 - 01052011

fl.saveAll();

fl.openDocument

l = fl.swfPanels.length;
if (l == 0) return 'false';
for (i=0; i<l; i++){
if (fl.swfPanels[i].name == p_panelName) return (p_param == null) ? fl.swfPanels[i].call(p_function) : fl.swfPanels[i].call(p_function, p_param);
}
return 'false';
}

call_method('gProject', 'runCompileList');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment