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.