Flex Drag And drop

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 me

Thanks 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?

Similar Messages

  • 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.

  • 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, Norman

    Here'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/

  • Can't drag and drop my iPhoto library on to an external hard drive (Seagate Go Flex).

    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,
    Josh

    Short 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 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,
    Thierry

    To 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 Patwari

    Thank 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

  • 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,
    Sujatha

    the 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 flex

    Try 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.

  • Flex 2:  Drag and Drop

    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.
    -alfie

    When 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

  • Problem with Drag and drop manager

    I am noticing that the sample provided at
    http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_7.html is not working when tried on any version of FireFox browser on a Mac OS version 10.6.3.
    So my understanding is that there seems to be some problem with the drag and drop manager in Flex when used on Firefox on a Mac OS version 10.6.3.
    It will be very helpful if you can provide any work around for this issue. We want to implement the drag and drop feature in a website that we are building for one of our clients.

    You must be an Oracle employee as you're referring to a component in the upcoming JDeveloper version which has yet been released to the general public. Oracle employee's are, I believe, directed to post on internal Oracle forums.
    CM.

  • Please Help! Drag and drop does not work in Adobe AIR 3.1 (FlashBuilder 4.6)

    I am working on a PC is made of air and flashbuilder 4.6.
    Drag and drop application does not work in Flash Builder 4.6.
    However, the same source will work with Flash Builder 4.5.
    Please help me.
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                                  xmlns:s="library://ns.adobe.com/flex/spark"
                                  xmlns:mx="library://ns.adobe.com/flex/mx"
                                  backgroundColor="#323232" width="100%" height="100%"
                                  initialize="init(event)"
                                  nativeDragEnter="onDragEnter(event)"
                                  nativeDragDrop="onDragDrop(event)">
              <fx:Script>
              <![CDATA[
                        import mx.events.FlexEvent;
                        protected function init(event:FlexEvent):void
                                  addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragEnter);
                                  addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
                        private function onDragEnter(event:NativeDragEvent):void
                                  if (event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT))
                                            NativeDragManager.acceptDragDrop(this);
                        private function onDragDrop(event:NativeDragEvent):void
                                  var arr:Array;
                                  arr = Array(event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT));
                                  startImage.source = (arr[0] as File).url;
                ]]>
              </fx:Script>
              <s:layout>
                        <s:VerticalLayout/>
              </s:layout>
              <s:BorderContainer id="bc" borderStyle="solid" width="200" height="80%"/>
              <s:Image id="startImage" width="100%" height="100%"
                                             horizontalAlign="center" verticalAlign="middle"/>
      </s:WindowedApplication>

    Thank you answers, but it was not the answer I wanted.
    [Problem]
    * Flash Builder 4.5.1(updater) or Flash Builder 4.6
    - If you have installed on pc, does not work adobe air drag and drop
    [Solution]
    1. Reinstalling the Windows 7 (32bit).
    2. Install Flash Builder 4.5.
    3. Flash Builder 4.5.1 updater and Flash Builder 4.6 does not install.
       (Instead of using Flex SDK 4.6 is set up)
    In addition, Windows7 64bit environment does not work drag and drop.
    Is there another solution?

  • Drag and drop does not work in Exported release build

    I am using the built in DragManager class to handle some drag and drop functionality in an application.  When running from flex builder, It runs exactly as expected, but when I export the project to a release build, Dragging only works in the vertical direction.  How is this possible?  What might be causing such strange behavior.
    Any help would be much appreciated.

    Sorry, I will try to be more clear.  I am using drag and drop simply to move items around on a Canvas.  This works perfectly when running from flex builder, but when i export a release build it starts behaving strangely.
    I can drag items up or down on the canvas no problem, but as soon as I try to drag items left or right, there is no response.  On a windows machine, it gives me the black circle with a slash through it icon, implying that the drag is not accepted.  On Mac, there is no icon, it simply will not drag. 
    Hope that clarifies it, I could really use some help figuring this issue out.
    Update:
    I can confirm that the call to DragManager.acceptDragDrop is being reached in both cases, but the DragEvent.DRAG_DROP event is not being handled in the release build, (it is reached when run from flex builder)

  • Drag and Drop - Drag Image

    I'm using the Flex DragManager in an AdvancedDataGrid with
    HierarchicalData to allow the user to drag and drop tree nodes to
    re-order them. It is working fine. The problem I am having is with
    the drag image. The drag image does not always show up. It seems
    like it will appear for one drag and drop. Then if I try to drag
    another tree node I do not get the drag image there is just a line
    to show I'm dragging something.
    When I say drag image I mean the faded image of the text of
    the tree node which appears as I drag the tree node.
    I am using the following properties on the AdvancedDataGrid
    to enable drag and drop:
    dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
    Now if set dragMoveEnabled="false" then I do get a drag image
    everytime. But I need move the tree nodes around not copy them so I
    need dragMoveEnabled="true".
    Thank you

    I'm using the Flex DragManager in an AdvancedDataGrid with
    HierarchicalData to allow the user to drag and drop tree nodes to
    re-order them. It is working fine. The problem I am having is with
    the drag image. The drag image does not always show up. It seems
    like it will appear for one drag and drop. Then if I try to drag
    another tree node I do not get the drag image there is just a line
    to show I'm dragging something.
    When I say drag image I mean the faded image of the text of
    the tree node which appears as I drag the tree node.
    I am using the following properties on the AdvancedDataGrid
    to enable drag and drop:
    dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"
    Now if set dragMoveEnabled="false" then I do get a drag image
    everytime. But I need move the tree nodes around not copy them so I
    need dragMoveEnabled="true".
    Thank you

Maybe you are looking for