Flex : How to start a flex/air app by dragging a file to the application Icon and got the file
I'm building a flex application
It has a functionality that can upload fil开发者_如何学Ces to server
The customer will want to open app by dragging file to the icon and the app will start and begin uploading. But I cannot find how to implement that
Can anyone help me? Any help or link will be great appreciated.
Edit: thanks to alxx
Here is my code
private function initComponents():void {
NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvokeEvent);
}
public function onInvokeEvent(invocation:InvokeEvent):void {
arguments = invocation.arguments;
currentDir = invocation.currentDirectory;
if(arguments.length > 0)
{
var dfile:File = new File(arguments[0]);
if(dfile.exists) {
if(ArrayUtil.getItemIndex(dfile.extension,ConfigManager.AllSupportedFileExtensions) > -1)
uploadQueue.push(dfile);
if(!logged)
Alert.show("Please login before upload");
}
}
}
Try listen to InvokeEvent.INVOKE of Application, as described here. You'll get full native path to dropped file in arguments array (just tested it myself.)
精彩评论