PDA

View Full Version : Forcing a Panel Open with JSFL


fgerantabee
03-26-2008, 05:33 PM
Hello all: i have written and packaged a JSFL command that automatically scripts a button instance in AS3. I find that my extension doesn't run properly if the Actions panel isn't already open.

Is there a way to open a panel in JSFL, either by a direct command or by executing an existing menu command (window>actions)?

Any help would be very appreciated.

====
Added
===

I want to mention that my JSFL works if the panel is not open, but only once the panel has been opened at least once (?????). If the Acitons panel is closed, it will still add actions to the selected keyframe, but will do nothing if I haven't opened and closed the panel at least once..very odd. For this reason, I'm still trying to figure out how to 'force' the panel open, either through some type of actionsPanel.open() command (which doesn't exist), or by forcing a menu command (Window > Actions).

Help!

funjoy
03-31-2010, 04:22 PM
I got that to work by setting the actionscript property of a symbolInstance instead of going through the actionscript panel and using setText().

I'm not sure what's the best way to get a reference to the symbolInstance you wish to add actionscript to but the following code works:
var doc = fl.getDocumentDOM();
var elementsNamedButton = fl.findObjectInDocByName("button", doc);
fl.selectElement(elementsNamedButton[0], false);
fl.getDocumentDOM().selection[0].actionScript = "on (release) {\n getURL('http://google.co.uk', '_blank');\n}\n";

What happens here is that you get an array of all the things named "button" with fl.findObjectInDocByName(). Then you select the first (and only) element of that array (unless you have many things named "button") and you change its actionScript Property.

I'm saying that I'm not sure of the best way to get a reference to the symbolInstance of my choice because the code above didn't work in a complex FLA. I ended up using fl.getDocumentDOM().getTimeline().layers[0].frames[0].elements[0].actionScript = "on (release) {\n getURL('http://google.co.uk', '_blank');\n}\n"; to dumbly select the first thing on the first frame of the first layer which happens to be the button I'm after.

I found that info on on the SymbolInstance page of the doc http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/js/html/wwhelp.htm?href=00004120.html