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

Similar Messages

  • Adobe Flex 4 Drag and drop example in application

    I have been looking at the following example:
    http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf64595-7fed.html#WS2d b454920e96a9e51e63e3d11c0bf69084-7cee
    The example works in web based flash project, but if I use the same code in a desktop AIR project image does not move to the mouse position. (this is obvilously after I have changed the Application container to a WindowedApplication container)
    It seems to be due to the fact that the parent container stops receiving mouse move events while dragging. The image then moves to a position relative the where the mouse clicked inside the image.
    I was hoping someone would be able to tell me what I am doing wrong?

    I've managed to solve the issue using event.localX instead.

  • Drag and Drop for File Uploads

    Hey,
    Is it possible to do this in Flex? Drag and Drop files into a flex app - to upload them later (say on a button click). I did some searching and found that it is possible to do this in AIR - drag files from the file system and drop it in the app. But our app is web based and will be running in a browser.
    Thanks

    I have suffered from this during the past three days.
    Firefox 23.0, Mozilla Firefox for Ubuntu canonical - 1.0
    on a 32-bit Ubuntu PC. So the system couldn't be more different.
    I was trying to upload .MP3 files of 27MB. From about a dozen attempts with one file, no success whatever. On the other hand a different file worked first time. But a later attempt with a 14 MB .wav failed, so it's not related to the file.
    On the other hand an upload with Chrome worked perfectly. So it does look like a browser problem.
    Watching the system monitor during upload, it runs freely for about 9MB, then stops abruptly. At the same time, the message at the bottom left of the browser window, relating to dl-web.dropbox, disappears.
    The text of the message differed between Firefox & Chrome, but I imagine that's just a textual, rather than a functional, difference.

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

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

  • 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

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

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

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

Maybe you are looking for

  • Format over catalog file, tried to recover file but now corrupt?!

    I recently performed a format of my hard drive.  When doing this, I did not back up my catalog file from photoshop elements(I have pse 8.0).  I backed up everything else, and I do have all of the original full size photo files from my hard drive, ~11

  • Automatic Time Sync on Gnome Desktop?

    What would you do to sync time on your Gnome Desktop? Gnome Settings for "Networktime" does not work for me caus it is deactivated after reboot.... All what i try to do with ntp does not work too... Is there any "easy" way to sync time?

  • Styling font

    Hello amigos/amigas. I am trying to style some font I'm importing from a simple .txt file. I know how to set the font family, size, etc. however, I want to change the style of the font as well as the family. The font I am defining is "frutiger", but

  • "Submit a review" feature on iweb site?

    Is it possible to use a service to allow a "submit your review" type of service to iWeb? I'm interested in allowing others to utilize a review-based system to build a sort of online reputation...any ideas?

  • Card reader - Slow Downloads

    For some unknown reason I am suddenly experiencing extremely slow downloads when attempting to download images from my compact flash cards using a card reader to an Iomega external drive. Until recently downloading a 16GB card to my external drive wo