I am trying to make my Air Captive Runtime Mac OS X app respond correctly when the user double clicks on a file type associated with the app.
I have set up the invoke event listener to capture location of the file that the user has clicked to launch the app stored in the event.arguments variable.
In the following simple test I just print out the length of the arguments passed in when the app is invoked. This is the behavior I am seeing:
1. when I launch the app from the command line with 2 args,
open test.app --args arg1 arg2
I get "2" as expected for the arguments length.
2. If the app is already open and I double click a file with a type associated with the app. It correctly invokes the app and passes in the path to the file that was clicked. Length is 1 as expected and the content is the path to the file.
3. However, if I just double click the same associated file when the app is not open, the app launches correctly, however no arguments are passed. Length is 0 and there is no way to know what file the user double clicked.
here is code:
var debugOutput = new TextField();
addChild(debugOutput);
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke);
function onInvoke(e:InvokeEvent):void
{
debugOutput.text = e.arguments.length;
}
Any thoughts on what might be going on?