Let me first state that I am very new to Flex/Flash/Illustrator. So please forgive me if I use the wrong terms or concepts. Using Illustrator CS5.1, Flex 3.6 SDK in Flash Builder 4.5, and Visual Studio 2010.
Some background. I am developing a hybrid plugin for Adobe Illustrator. The plugin is C++ and interfaces with a hardware device and an UI extension built on Flex/Flash. It uses the CSXS library (version 2.0 based on Flex 3.4 SDK) to perform the communication between the extension and the plugin.
When the UI extension closes, I need the plugin to perform some tasks. These tasks might be related to Illustrator and/or to the device it communicates with. If the UI is closed using a button I add to the UI, the plugin runs the tasks as needed. If the UI is closed using the 'X' button in the corner of the window, I can not get the CSXS interface dispatch events to carry over to the plugin. This is the same dispatch events used from the UI button that I manually created and works fine.
I have tried capturing the exiting event from the NativeApplication and I do see myself entering the associated function to that capture. The dispatch events run but I do not enter the corresponding functions in the plugin.
Below is one of several attempts at making this work (believe this was found on the Adobe forums):
public function init() : void
protected function windowedapplication1_closingHandler(event:Event):void
CSXSInterface.getInstance().dispatchEvent(new CSXSEvent("com.testui.events.closing", CSXSEventScope.APPLICATION));
Again, windowedapplication1_closingHandler will process but the dispatched event is not seen by my plugin (when the 'X' is clicked).
I am open to doing this other ways.
Is there a way to disable/hide the 'X' in the corner of the window?
Am I just missing something obvious that would make the above work? Am I not properly "capturing" and "halting" the exit event?
Should I move away from the CSXS Library and use sockets to perform this communication (though the closing of the extension may have the same affect on the socket communication)?
I am currently working on Windows 7 64-bit (if that matters) but the plugin will have to work on Mac too.
Thank you for your time.
You could try asking/searching in the Creative Suite SDK or Extension Builder forums, you may get a response there since it sounds like the problem is with the CS Extension side of your hybrid extension. I'm afraid I can't think of a solution off the top of my head - others have had similar problems.
Sorry I can't be of more help,
Th CS SDK forum is probably better for CS Extension specific questions.
The correct way to handle it would probably be to listen for the standard StateChangeEvent fired when the panel is closed. If I recall correctly, the events are not fired correctly in Illustrator.
You can create a "close" event handler for your extension and do whatever you like in that handler. The close event is launched when the extension is closed. The problem is that no events are launched in Illy when the panel is closed. It remains in a ghost state. It "thinks" it's really open. You can try to work up the parents of the extension and attach an event listener to the StageManager (I think it's 4 levels up). I don't know if it will work...
You can also try to poll the status of the extension from your C++ plugin, but I'm not sure that you will get the correct status back.
The CSXS architecture in Illustrator is a mess. Most of the other apps are a lot better.
Innovations in Automation
Thank you both for your responses. I will see about moving/re-posting this in one of the other forums (I truly was at a loss of where to put this post).
I will also look some more at the other events that are fired off and see if any of those help. Polling was something that I had thought about trying but figured there had to be a better way of making this work.
Thanks again for your time.
Europe, Middle East and Africa