Now I'm on-going developing an Air desktop application in which remote files need to be dragged out and stored in local file system.
Remote files can be dragged out and stored in local file system in my demo project,however when I merged the demo code to my
app project,it can't work correctly.I find that the URLStream wasn't connected as I registered a function to listen the
event: Event.OPEN
and the listener function wasn't called.
And also there is no corresponding http request captured with the capture utility:Wireshark.
Could anyone give me some tips to work out the problem.
Thanks a lot!
Below is my code:
{
var dragAttach:Clipboard = new Clipboard();
if(true == dragAttach.supportsFilePromise)
{
var filePromise:URLFilePromise = new URLFilePromise();
var attachURl:String = GlobalConfig.HTTP_SERVER_ADDRESS +
"/" + _srcUname +
"/" + _fileType +
"/src/" + _attachID;
trace(attachURl);
filePromise.addEventListener(Event.OPEN, onURLStreamOpen);
filePromise.addEventListener(IOErrorEvent.IO_ERROR, onError);
filePromise.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecrityError)
filePromise.addEventListener(ProgressEvent.PROGRESS, onProgress);
filePromise.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus);
//attachURl = "http://192.168.6.229/dragAttach/hello.png";
attachURl = "http://ln.cn/swf/mm.png";
trace(attachURl);
filePromise.request = new URLRequest(attachURl);
filePromise.relativePath = _fileName;
var fileList:Array = new Array();
fileList.push(filePromise);
// only allow the file to be copied
var dragOptions:NativeDragOptions = new NativeDragOptions();
dragOptions.allowMove = false;
dragOptions.allowCopy = true;
dragOptions.allowLink = false;
var setRes:Boolean = dragAttach.setData(ClipboardFormats.FILE_PROMISE_LIST_FORMAT, fileList);
this.addEventListener(DragEvent.DRAG_COMPLETE, onDragComplete);
NativeDragManager.doDrag(this,
dragAttach,
_dragImage,
new Point(-mouseX, -mouseY),
dragOptions);
}
return;
}
North America
Europe, Middle East and Africa
Asia Pacific