explorers' club

explorations in dev, science, sci-fi, games, and other fun stuff!

Native Flex Drag & Drop Tip

4 Comments

[note to self]

The native Flex drag and drop from list-based components is pretty neato.  With just a few hookups to drag events, you can easily drag objects out of a list to a receipient component.  One point of annoyance with the native drag n’ drop is the lack of the draggedItem being easily accessed.

By default the draggedItem property of most drag events is null through out the entire dragging process.  This is absurd in my book.  The only time this gets populated is through automation hookups which I know nothing about.  Even assigning the public var draggedItem does not work as it is rendered null during the dragging process.  So how does one go about geting the actual dragged item?

Assuming for the moment you are trying to access a single dragged item you would simply say:

DragEvent(evt).dragSource.dataForFormat("items")[0];
Advertisements

4 thoughts on “Native Flex Drag & Drop Tip

  1. Can’t agree more^^ Thanks for the tip!!

  2. Love Flex but this Drag/Drop stuff is so counter intuitive, like a foreigner wrote it.

    • I completely understand your frustration. However I would note, that after looking at some HTML5 drag and drop examples, they also have some equally baffling logic. Most especially: in order to drag an item from one container to another, you have to call preventDefault on the drag events. I am sure there are good reasons for why both the Flex and HTML5 drag n’ drop processes are somewhat of a chore to customize (for what you or I’d call normal drag n’ drop operations) but I have not discovered why. Given that both technologies have accessible work arounds, I can’t complain.

  3. does not work for me 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s