Skip navigation
comefuncity8
Currently Being Moderated

Question on URLFilePromise for dragging remote file out

Dec 25, 2011 4:35 PM

Tags: #flex_4.5.1

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:

 

private function onMouseDown(event:MouseEvent):void

 

{

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;

 

    }

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points