onDragDrop This page was last modified over 30 day(s) ago and has 3 comment(s)

Back to Application Class Summary

Windows, Mac OSX, Linux




Dispatched when the user drags and drops a file or folder onto the application. The event object data will contain "files" array containing the dropped file(s)/folder(s)

This event will only be dispatched when drag and drop behaviour has been activated for the Form with Forms.dndEnable().

There are two ways to listen for events in 4.0:
using "onEventNameFunction" - callback based handlers introduced in {mdm} 2.0
using IEventListener model based on Events introduced in 4.0.

No matter what implementation you would use either callback and listener handler would have to use single-argument defintion as in below sample:
// callback based handlers
mdm.Appllication.onAppChangeFocus = function(event:Event):void
// proceed with event

// handlers based on IEventListener model
function onAppChangeFocusHandler(event:Event):void
// proceed with event

Example Code
// callback based handler
mdm.Application.onDragDrop = function(event:mdm.Event):void
var files:Array = event.data.files;
// event-listener model
function onDragDropHandler(event:mdm.Event):void
var files:Array = event.data.files;
mdm.Application.addEventListener("onDragDrop", onDragDropHandler);

mdm.Application Class Example Downloads
No Example Downloads Available

User Comment by mike g on 6th August 2012 - 21:05
Seems like the event-listener model doesn't get triggered. Zinc v 4.0.7 Mac

User Comment by mike g on 6th August 2012 - 21:13
In the example, seems like the "data" contains the array, not "files"

Should be:
var files:Array = event.data;

User Comment by mike g on 6th August 2012 - 22:38
The event type should not be set to "mdm.Event"

mdm.Application.onDragDrop = function(event:mdm.Event):void

mdm.Application.onDragDrop = function(event:*):void

... otherwise the Flash compiler complains: "Ambigous reference to Event" for the rest of your script, (if you have other "Event" stuff in your script.

Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page