| Previous | Next | |
This sample shows how to enable your application to accept and handle drag-and-drop files using the mWindow.onDragFiles() and mWindow.onDropFiles() event handlers, respectively.
mWindow.onDragFiles() provides a list of files dragged onto the application. Code in this event handler can test the extension of each file. If an extension type matches a file type that the application accepts, the handler returns true.
mWindow.onDragFiles = function(files) {
var extension:String;
var okToDropThisFile:Boolean = false;
for (var i = 0; i<files.length; i++) {
if (!mFile.isFolder(files[i])) { // do not accept folders
extension = getFileExtension(files[i]);
if (extension == "swf") {
okToDropThisFile = true;
}
}
}
return okToDropThisFile;
};
mWindow.onDropFiles() provides an array of files dropped on the application and opportunity to take action on the drop event
You can download this sample, "dragAndDrop", from the mProjector Samples page -- http://www.screentime.com/software/mprojector/flas.html#dragAndDrop.
| Questions or Feedback? | Previous | Next |