Tutorial: Flex Drag and Drop
I have just published a tutorial on Drag-and-Drop in Flex:
http://www.flexafterdark.com/tutorials/Flex-Drag-and-Drop
I hope it is helpful and would certainly appreciate any feedback you are willing to share.
Thank you.
Ben Edwards
Ben, I have a Drag & Drop related question. Please see:
http://forums.adobe.com/thread/534259?tstart=0
Thanks.
Similar Messages
-
Hello All,
I'm having problems suspending a drag and drop operation based on User input from an Alert prompt. i have a flex tree that acts as a drag initiator and a drop target as well (Dragging items of the tree within the tree itself) I'm trying to do a drag and then fire an alert prompt asking the user something like "Are you sure you want to move this item? Yes or No" when the item is dropped to a different location in the tree.
My first problem was that, the item is moved regardless of the outcome of the user's choice and i had to do an event.preventDefault() on the Drag drop handler to stop this from happening, After which i put my own custum logic saving the drag event to a variable to later redispatch it to complete the DnD process (Which seems rational).
My question is, Am I suspending the right type of event? How do i get something as simple as this working. After a while i started receiving this error "Error: Attempt to access a dead clipboard", is this a bug with the flex framework.
Any form of help will be very much appreciated, i also googled, stackoverflowed, and looked through every flex cookbook i know but no solution.
Please help meThanks Alex.
So are you saying this is almost impossible? Is there a way to somehow add the item to the tree's datapovider without showing a visual feedback in the tree. That is making the Tree UI not reflecting the newly added item after the drop, then showing the alert, getting the users input then doing a final clean up in the tree (by calling tree.invalidateList()//tree.validateNow()/or refreshDataProvider ) on dragComplete.
whats your opinion on this? -
Hi guys.
I just finished reading the Java tutorial on Drag and Drop at http://download.oracle.com/javase/tutorial/uiswing/dnd/index.html.
Unfortunately, there is no note about how to drag and drop a custon object. There is something said on DataFlavor, but not enough to help me.
So I would appreciate it if anyone could tell me the steps to follow when dragging and droping a custom object.
Best regards.
EdmondI think we can help you, but please post some example/code of what you are trying to achieve.
I made D&D with custom objects, custom icons, etc. and is not so hard ... like I said, post some code ...
RGV -
Drag and drop questions using image and painting
Hi all,
please apologize me if i'm posting a just discussed topic, but I couldn't find anything that could help me.
I'm trying to create an application where I've a Jtree on the left panel that contain entities that have to be dragged and dropped in the central panel (eventually pasting a representative image) as user decide.
I've just implemented all panels and jtree. I read java tutorial on drag and drop, but I don't know HOW i can paste image as objects that then i can manipulate in such a way that the user needs.
Do I have to use java.awt.dnd package?
Please, I'd like to receive some suggestion about.
Thanks in advance for your kindness.
VincenzoI'm sorry, I think that i've not been clear in my explanation. I don't know how to transfer by drag & drop an image (a node of a jtree) to a beside panel. I don't want to get code, it will be more appreciate suggestions on how to proceede.
I don't understand if I need java.awt.dnd package. On java tutorial I read that it shouldn't have to be used.
Thanks, I hope that I've been clearer now. -
Flex mobile support drag and drop
According to Adobe's "Developing Mobile Applications in Flex" document it doesn't. But I was wondering if that applies to both mobile phones and tablets, or only to mobile phones. Can this feature be added manually through ActionScript 3?
Thanks, NormanHere's a hack that you might be able to make work for you...
http://flexponential.com/2011/06/21/using-drag-and-drop-with-a-spark-list-in-a-mobile-flex -application/ -
I am trying to move my iPhoto library to an external hard drive (Seagate Go Flex wireless) but it won't let me drag and drop. When I drag the iphoto icon over the 'drop files here' it just disappears. No error message. I am running mountain lion. What can I do?
Susie,
(Seagate Go Flex wireless)
What is your iPhoto version? And your Mac OS X version?
With iPhoto '11 your iPhoto library needs to be on a drive formatted Mac OS X Extended (Journaled). Is your external drive formatted this way? If your drive is formatted differently, iPhoto will not be able to open the iPhoto library there.
When I drag the iphoto icon
And are you really trying to drag your photo library (from your "Pictures" folder) or your iPhoto application from the "Applications" folder? On MAcoS X 10.7 or later you will not be able to drag the application from the Applications folder.
Regards
Léonie -
Drag and drop external text into a Flex component
Hi,
is there any way to allow drag and drop of external text (for
example, selected text from another browser or even from the
address bar) into a Flex component like TextArea? I know how to
drag and drop between two different Flex components but in this
case, the source is external. There must be something I can do to
TextArea like its dragdrop property to allow this feature... any
help would be greatly appreciated.
Thanks,
JoshShort answer: Yes, as long as it is an AIR app.
Browser-based Flex apps do not have access to
ClipBoardFormats, so I'm not sure it is possible to do what I think
you want to do -- have a web-based Flex app that allows you to drag
and drop selected text from other apps. Most possibly because of
the security sandbox that the Flash player runs in.
However, if you wanted to do it in an AIR app, I built this
as an example for you (you can view a "cleaner" version with proper
indents at
http://pastebin.com/f741cbac8
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="
http://www.adobe.com/2006/mxml"
creationComplete="initDandD();" width="500" height="600">
<mx:Script>
<![CDATA[
public function initDandD():void {
addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,
onDragIn);
addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,
onDragDrop);
private function onDragIn(e:NativeDragEvent):void {
if(e.clipboard.hasFormat(ClipboardFormats.TEXT_FORMAT)) {
NativeDragManager.acceptDragDrop(this);
private function onDragDrop(e:NativeDragEvent):void {
var myString:String =
e.clipboard.getData(ClipboardFormats.TEXT_FORMAT) as String;
myTextArea.text = myString;
]]>
</mx:Script>
<mx:TextArea id="myTextArea" width="326"
height="262"/>
</mx:WindowedApplication> -
Drag and Drop Tutorial -- Most Requested
Tutorial for one of the most reqeusted questions made! how to make drag and drop in Adobe Edge Animate , Check it out : http://www.edgehero.com/tutorials/draganddrop
[url http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html]Introduction to Drag and Drop
-
Drag and drop a image from html page into flex
how can i drag a image form the html page and drop it into
the flex application.Hi,
There's no direct support for this. But you could implement
drag and drop the way you normally would in javascript. Except
here, on mouseUp over a div encapsulating the object or embed tag
(the flash object), you'll need to make a call into actionscript
from javascript indicating that a drag and drop happened.
For more info, see
how
to drag and drop using javascript and
actionscript
and javascript communication -
Drag and Drop between Flex application
Hello,
Can we implement the Drag and Drop functionality between 2
FLEX applications?
Each flex application is in its own IE.
Thank you,
ThierryTo my knowledge you can't drag and drop anything between 2
windows in a browser using any technique in the way that you mean.
In other words, I don't think you can even do this in javascript
between 2 windows.
You can use LocalConnection to simulate this though, by
having the drag manager notify the other application when it leaves
the stage, so that when you reach the other application it will
start the drag effect again in that window. -
Drag-and-drop from desktop to Flex app
I am working on a RIA using flex and am trying to implement drag and drop of different types of files into a Flex UI, I know this is possible using AIR but we are trying to do it through Flex in a browser. Trying out options with javascript and active x controls but no success till now.
I am seeking pointers to any sites that implemented this or any direction on cracking this one.
Thanks,
Rakesh PatwariThank you for the quick response Jeffry,
Yes, I am facing that issue whichever way we are going in! How about using Javascript/HTML as iframe within flex to get this done?
Just thinking about it...
Thanks again,
Rakesh Patwari -
Recommend me a good drag and drop tutorial
I need to make a movie whereby the user drags four items onto 4 targets and achieves a result as each object lands on the target, such as a sound. and then a well done statement at the end.
Can anyone recommend me a place where I can download such a file so I can manipulate it? I figured an hour ago when i sat at my computer that I would find one easily, but I'm really stuck now. can anyone suggest a tutorial/ site where I could get a free download of an advanced drag and drop like this?
I'd really appreciate your help!
Thanks.
Niamh.These are the 2 good tutorials that helped me in making Drag and Drop in flash : http://www.flashvalley.com/fv_tutorials/advanced_drag_and_drop_in_Flash/
http://www.actionscript.org/resources/articles/26/1/Drag-n-Drop-and-Drop-Targets/Page1.htm l
Thanks,
Sudheendra -
Help needed in drag and drop of Flex tree
Hi,
We have an application which allows drag and drop between
multiple
trees and lists.
Here are the steps I follow to refresh on drag and drop:
1. Dispatch a custom event which calls server.
2. On successful response from server I change the model
which is
data provider for the tree.
3. Then, set a flag which triggers 'invalidateDisplayList'
and 'invalidateList' for tree (and other listeners).
4. The tree refreshes fine. But as soon as I drag and drop
between
trees again, I get this error in Tree.as:
TypeError: Error #1010: A term is undefined and has no
properties.
at mx.controls::Tree/::updateDropData()
at mx.controls::Tree/calculateDropIndex()
at mx.controls.listClasses::ListBase/showDropFeedback()
at mx.controls::Tree/showDropFeedback()
The behaviour is weird, sometimes the browser hangs and stops
responding.
I am calling 'contentTree.showDropFeedback(event)' in my
dragOver
event listener which is triggering error.
My tree data provider is a custom class which has 'children'
array
collection attribute.
Any help on how to resolve this issue would be highly
appreciated.
Thanks in advance,
Sujathathe major restrictions in its implemented only in
jdk1.1.Why! -
Drag and drop images using tilelist in flex
i just want the working code for drag and drop images using
tilelist in flexTry JDK 1.4 and call setDragEnabled(true)
I will also post updated version of MediaChest soon using custom TransferHandler for DnD different types of Objects. -
Hi,
I need help or maybe I can get some advice. I have a TileList
that gets populated by buttons. I am using HTTPService as my
WebService. I have a component called Buttons.mxml, to use as
itemRenderer for my TileListEx.mxml. Everything is good as far as
displaying all my buttons onto my TileList. My problem is when
doing Drag-and-Drop. Right now when I drag a button and drop it in
to a different spot/location (inside my TileList), it moves the
other buttons too at the same time. I cannot drop a single button
onto an exact position without affecting the other buttons. Is
there a way to when you do a drag and drop, it will drop the item
onto exact position as to where you wanted to drop it in. I
attached my sample code, maybe someone can help me and give me some
advice onto how to fix my problem or maybe can tell me a better
solution of doing this.
Buttons.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="
http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalGap="0" horizontalGap="0" >
<mx:Button label="{data.name}" width="100" height="50"
textAlign="center" />
</mx:VBox>
TileListEx.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
xmlns:local="*" layout="absolute" backgroundAlpha="0"
creationComplete="itemRequest.send()">
<mx:HTTPService id="itemRequest"
url="C:/TestFlex/menuitem.xml" useProxy="false" />
<mx:VBox x="10" y="41" width="1000" height="550">
<mx:Panel width="575" height="550" layout="absolute"
id="menuItm" title="Fruits">
<mx:TileList direction="vertical"
dataProvider="{itemRequest.lastResult.menuitem.items.item}"
height="100%" width="100%"
itemRenderer="Buttons" rowHeight="60" columnWidth="110"
dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
dragEnter="true"/>
</mx:Panel>
</mx:VBox>
</mx:Application>
My menuitem.mxml
<?xml version="1.0" encoding="Utf-8" ?>
<menuitem>
<items><item><name>Combo Chz
Burg</name></item>
<item><name>Burger</name></item>
<item><name>Cheese
Burger</name></item>
<item><name>Bac Chz
Burger</name></item>
<item><name>Lumberjack</name></item>
<item><name>Boomer
Burger</name></item>
<item><name></name></item>
<item><name></name></item>
<item><name>Double
Play</name></item>
<item><name></name></item>
<item><name>No Roll</name></item>
<item><name></name></item>
<item><name>Well Done</name></item>
<item><name>Rare</name></item>
<item><name></name></item>
<item><name></name></item>
<item><name>Sausage</name></item>
<item><name>Pulled
Pork</name></item>
<item><name>Grilled
Cheese</name></item>
<item><name></name></item>
<item><name>Chicken
Little</name></item>
<item><name>King of
Klubs</name></item>
<item><name></name></item>
<item><name></name></item>
<item><name>Do It To
It</name></item>
<item><name>Sub</name></item>
<item><name></name></item>
<item><name>Hot Drink</name></item>
<item><name>Bottle
Water</name></item>
<item><name>Soda</name></item>
<item><name></name></item>
<item><name></name></item>
<item><name>Open Food</name></item>
<item><name>Eat In</name></item>
<item><name>Take Out</name></item>
<item><name>Phone
Order</name></item>
<item><name>Extra</name></item>
<item><name>Orange</name></item>
<item><name></name></item>
<item><name></name></item></items>
</menuitem>
Thank you very much in advance.
-alfieWhen working with drag and drop, troubleshoot starting with
the most obvious: Where exactly is the Canvas you're dropping onto
and how large is it. Give the Canvas a temporary red background
(myCanvas.setStyle("backgroundColor", "#FF0000")) to see exactly
where it is on the stage. If you can't see it after you've changed
the background color, chances are you can't drop anything onto it
either.
Glancing over your code I see a couple things:
1. In DesignCanvas, you don't define the dropTarget variable,
which is supposed to be a reference to the DesignCanvas.
private function doDragEnter(event:DragEvent):void
var dropTarget:Canvas = this;
DragManager.acceptDragDrop(dropTarget);
2. Your override of updateDisplayList() doesn't include
super.updateDisplayList(unscaledWidth, unscaledHeight);
I'd comment out your complete updateDisplayList() override
and troubleshoot the drop target first, then you can start adding
the other functionality and see if it works as you'd like.
P.S. Just as a best practice, start your classes with
uppercase and variables and functions lowercase, so DesignCanvas,
not designCanvas.
TS
Maybe you are looking for
-
I have an Ipod Touch 2 and rebuilt my laptop. Reinstalled ITUNES and can't find my applications on ITunes after login. I tried to activate Itunes again but it didn't. How can I get my applications to display on ITUNEs?
-
I'm one of those rare fruit (Mac) users who doesn't care for itunes or anything of the sort (I'm really not a Mac fan; I got the computer because I can abuse it more and have it still function with the solid state hard drive). I hate seeing updates f
-
Automating the services for object for a work order
Hi All, Can anyone post an ABAP code using which we can automate the process of creating a note for a Work order at the time of saving the work order. I need to create a note with the work order at the time of saving it. This note needs to be attache
-
HT201303 my account been locked, how i can open it again
I forgot my security question and my account been locked. How can i open it again???/
-
LMS 4.2.3 - C6500 VSS - Issue with inline card on secondary chassis
Hello, We are currently setting up a fresh new LMS 4.2.3 server to administrate a 90 LAN-device-perimiter. Installation is OK (on a Windows Server), devices are up, monitored and their configurations archived. The core switches are Catalyst 6506 VSS