Problem with drag and drop multiple lines of ListView

I work on an example application with 2 views of list that is the players and the team and implement drop and drop as players can be deposited to one list to the other. Everything works as expected when there is selection unique model is enabled in the source list view. However, if I have activated several model selection and drag 2 or more lines of source target list view list view, see the following exception after that the decline is over.

Exception:

java.lang.IllegalArgumentException: only objects serializable or ByteBuffer can be used as data with the format of data [subListPlayers]

at com.sun.javafx.tk.quantum.QuantumClipboard.putContent(QuantumClipboard.java:513)

at javafx.scene.input.Clipboard.setContent(Clipboard.java:230)

(1) what should be the DataFormat used to be able to drag and drop multiple lines? Looks like we don't have for the type of object, so I created the following which does not solve the problem.

private DataFormat dataFormat = new DataFormat ("subListPlayers");

(2) I made changes to support serialization on the data object that seems no more to solve the problem. Tried by implementing the interface Serializable, as well as the implementation of the Externalize interface.

Can someone Guide please if there is an easy way to implement this behavior?

Code:


public class player

{

private String name;

public player (String name)

{

myIdName = name;

}

public String getName()

{

return the name.

}

public void setName (String name)

{

myIdName = name;

}

@Override

public boolean equals (Object o)

{

If (this == o) return true;

If (o == null | getClass()! = o.getClass ()) return false;

A player = o (player);

If (name! = null? name.equals (player.name): player.name! = null) return false;

Returns true;

}

@Override

public int hashCode()

{

return the name of! = null? name.hashCode (): 0;

}

}

SerializableAttribute public class JavaFXDnDApplication extends Application

{

private final static ListView < drive > playersListView = new ListView < drive > ();

private final static ObservableList < drive > /playerslist is FXCollections.observableArrayList ();.

private final static ListView < drive > teamListView = new ListView < drive > ();

private final static GridPane rootPane = new GridPane();

private DataFormat dataFormat = new DataFormat ("subListPlayers");

Public Shared Sub main (String [] args)

{

Launch (args);

}

@Override

public void start (point primaryStage)

{

primaryStage.setTitle ("Drag and Drop Application");

initializeComponents();

initializeListeners();

buildGUI();

populateData();

primaryStage.setScene (new scene (rootPane, 400, 325));

primaryStage.show ();

}

Private Sub initializeListeners()

{

playersListView.setOnDragDetected (new EventHandler < MouseEvent >)

{

@Override

public void handle (event MouseEvent)

{

System.out.println ("setOnDragDetected");

Dragboard dragBoard = (TransferMode.MOVE) playersListView.startDragAndDrop;

ClipboardContent content = new ClipboardContent();

content.putString (playersListView.getSelectionModel () .getSelectedItem () .getName ());

Content.put (dataFormat, playersListView.getSelectionModel () .getSelectedItems ());

dragBoard.setContent (content);

}

});

teamListView.setOnDragOver (new EventHandler < DragEvent >)

{

@Override

public void handle (DragEvent dragEvent)

{

dragEvent.acceptTransferModes (TransferMode.MOVE);

}

});

teamListView.setOnDragDropped (new EventHandler < DragEvent >)

{

@Override

public void handle (DragEvent dragEvent)

{

String player = dragEvent.getDragboard () .getString ();

ObservableList < drive > drive = dragEvent.getDragboard () .getContent (dataFormat) (< drive > ObservableList);

String player = dragEvent.getDragboard () .getString ();

teamListView.getItems () .addAll (New Player (player));

playersList.remove (new Player (player));

dragEvent.setDropCompleted (true);

}

});

}

Private Sub buildGUI()

{

rootPane.setGridLinesVisible (true);

rootPane.setPadding (new Insets (10));

rootPane.setPrefHeight (30);

rootPane.setPrefWidth (100);

rootPane.setVgap (20);

rootPane.setHgap (20);

rootPane.add (playersListView, 0, 0);

rootPane.add (teamListView, 1, 0);

}

Private Sub populateData()

{

() playersList.addAll

New Player("Adam"), New Player("Alex"), Player ("Alfred") New Player("Albert") new,.

New Player("Brenda"), New Player("Connie"), Player ("Derek") new new Player ("Donny").

Player ("Lynne") new, New Player ("Myrtle"), Player ("pink") New Player("Rudolph") new,.

Player("Tony") new, New Player ("Trudy"), Player ("Williams") New Player ("Zach") new

);

playersListView.setItems (playersList);

}

Private Sub initializeComponents()

{

playersListView.setPrefSize (250, 290);

playersListView.setEditable (true);

playersListView.getSelectionModel () .setSelectionMode (SelectionMode.MULTIPLE);

playersListView.setCellFactory (new reminder < < drive > ListView, ListCell < drive > > ())

{

@Override

public call for ListCell < drive > (ListView < drive > playerListView)

{

return again ListCell < drive >)

{

@Override

protected void updateItem (player, boolean b)

{

super.updateItem (reader, b);

If (player! = null)

{

setText (player.getName ());

}

}

};

}

});

teamListView.setPrefSize (250, 290);

teamListView.setEditable (true);

teamListView.getSelectionModel () .setSelectionMode (SelectionMode.MULTIPLE);

teamListView.setCellFactory (new reminder < < drive > ListView, ListCell < drive > > ())

{

@Override

public call for ListCell < drive > (ListView < drive > playerListView)

{

return again ListCell < drive >)

{

@Override

protected void updateItem (player, boolean b)

{

super.updateItem (reader, b);

If (player! = null)

{

setText (player.getName ());

}

}

};

}

});

}

}


Yes, it is a pain. I filed https://javafx-jira.kenai.com/browse/RT-29082 earlier. Go ahead and vote in favour if you're inclined...

I think that the problem in your case, it is the observable list provided by MultipleSelectionModel.getSelectedItems () is not serializable. So even if you make your player Serializable class, the list is not. The first thing I would try, I think, is to make player implements Serializable and pass in an ArrayList instead of the observable list. If you can do

content.put(dataFormat, new ArrayList(playersListView.getSelectionModel().getSelectedItems()));

and

List player = (List) dragEvent.getDragboard().getContent(dataFormat);
teamListView.getItems().addAll(player);

If it does not, a solution is simply to store the "slipped" into a property list:

final ListProperty draggedPlayers = new SimpleListProperty();
//...
// Drag detected handler:
content.putString("players");
draggedPlayers.set(playersListView.getSelectionMode().getSelectedItems());

// Drag dropped handler:
if (dragboard.hasString() && dragboard.getString().equals("players")) {
     teamListView.getItems().addAll(draggedPlayers.get());
     draggedPlayers.set(null);
}

Tags: Java

Similar Questions

  • problem with drag and drop

    Hi I have a problem with drag and drop I have 2 clip and I have 2 target, I want when I drag the clip 1 to 1, target 1 to target not accepts the clip2, clip 2 can therefore be enjoy to target 2. (target 1 can accept clip 1 and clip 2, target 2 can also clip accepts 1 & 2)

    Stone

    clip_piere.addEventListener (MouseEvent.MOUSE_DOWN, dep_piere);

    clip_piere.addEventListener (MouseEvent.MOUSE_UP, arreter_piere);

    clip_piere.buttonMode = true;

    var x_piere, y_piere:Number;

    x_piere = clip_piere.x;

    y_piere = clip_piere.y;

    function dep_piere(event:MouseEvent):void

    {

    clip_piere.StartDrag ();

    }

    function arreter_piere(event:MouseEvent):void

    {

    If (place1.hitTestObject (clip_piere): place2.hitTestObject (clip_piere)) {}

    clip_piere.stopDrag ();

    clip_piere. RemoveEventListener (MouseEvent.MOUSE_DOWN, dep_piere);

    } else {}

    clip_piere.x = x_piere;

    clip_piere.y = y_piere;

    clip_piere.stopDrag ();

    }

    }

    EAN

    clip_ean.addEventListener (MouseEvent.MOUSE_DOWN, dep_ean);

    clip_ean.addEventListener (MouseEvent.MOUSE_UP, arreter_ean);

    var x_ean, y_ean:Number;

    x_ean = clip_ean.x;

    y_ean = clip_ean.y;

    function dep_ean(event:MouseEvent):void

    {

    clip_ean.StartDrag ();

    }

    function arreter_ean(event:MouseEvent):void

    {

    If (place1.hitTestObject (clip_ean): place2.hitTestObject (clip_ean)) {}

    clip_ean.stopDrag ();

    clip_ean. RemoveEventListener (MouseEvent.MOUSE_DOWN, dep_ean);

    } else {}

    clip_ean.x = x_ean;

    clip_ean.y = y_ean;

    clip_ean.stopDrag ();

    }

    }

    Here is a link to a file that I did for you based on your objects and what I described in my last answer.  I reduced the code so that the
    the objects share the same functions.  I moved the MOUSE_UP listener on stage so that it is less prone to failure should drag you the object when slide it / drop.

    http://www.nedwebs.com/Flash/AS3_Drag_Targets.fla

  • Problem with Drag and Drop (Captivate 8)

    I have a drag and drop set-up of four headers that must be moved to the appropriate columns.  Objects and targets have all been defined properly.  I also have a "Submit" and "Reset" this button.  I've set up two shares advanced to be executed on the success and failure, respectively.  The approach of successful shows 4 points (a smart shape, 2 text boxes and a button 'Continue'), failure is supposed to show 4 points higher (a smart shape, 2 text boxes and a button "try" again).

    The "Success" action advanced works perfectly.  The action of the Advanced 'failure' is not.  Nothing appears when you provide inaccurate answers, he keeps just a static screen.  The reset button will attempt to reset however.  Must I specify somewhere that all the wrong answers must display text of failure.  I want the text to display if any of the four headers are placed correctly and I thought he would do this by default.

    What Miss me?

    That's what I thought, endless attempts.

    I know it's confusing, but the action of 'Failure' is actually an action "after the last attempt" that you can find for Question slides. This means that infinite attempts, it will never be executed and should be grayed out, but sorry it won't be dimmed. Unlike the legend of default that will appear after each failure. Little inconsistency...

  • How to rotate the movieclip with drag and drop?

    Hello everyone,

    I work with drag and drop game.

    I'm done with drag and drop. now, I have problem in totating the movieclip.

    I want video clip rotate using the mouse. Do not use the click mouse. !!!

    Can someone give me a solution for this?

    var isDrageen:Boolean;

    var lastX:Number;

    var derriГЁre: Number;

    var dragX:Number;

    var dragY:Number;

    stage.addEventListener (MouseEvent.MOUSE_DOWN, down);

    stage.addEventListener (MouseEvent.MOUSE_UP, up);

    stage.addEventListener (MouseEvent.MOUSE_MOVE, mov);

    function down(e:MouseEvent):void {}

    isDrageen = true;

    lastX = mouseX;

    derriГЁre = mouseY;

    }

    function up(e:MouseEvent):void {}

    isDrageen = false

    }

    function mov(e:MouseEvent):void {}

    {if (isDrageen)}

    dragX = mouseX-lastX;

    dragY = mouseY-derriГЁre;

    MC.rotationY += dragX/1.65;

    MC.rotationX += dragY/1.65;

    lastX = mouseX;

    derriГЁre = mouseY;

    }

    }

  • Hi help me with drag and drop with as3 if you please

    Hello friends,

    I am a newbie to as3 in flash and had a prob with drag and drop features

    var dragArray:Array = [square_word, circle_word, triangle_word];

    var matchArray:Array = [squareMatch, circleMatch, triangleMatch];

    var posArray:Array = [{x: 276, y: 207}, {x: 443, y: 207}, {x: 107, y: 207}];

    var currentClip:MovieClip;

    var startX:Number;

    var startY: number;

    for (var i: int = 0; i < dragArray.length; i ++) {}

    dragArray [i] .buttonMode = true;

    dragArray [i] .addEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

    matchArray [i] .alpha = 0.2;

    }

    function item_onMouseDown(event:MouseEvent):void {}

    currentClip = MovieClip (event.currentTarget);

    startX = currentClip.x;

    startY = currentClip.y;

    addChild (currentClip); bring to front

    currentClip.startDrag ();

    stage.addEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);

    }

    function stage_onMouseUp(event:MouseEvent):void {}

    stage.removeEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);

    currentClip.stopDrag ();

    var int index = dragArray.indexOf (currentClip);

    var matchClip:MovieClip = MovieClip (matchArray [index]);

    If (matchClip.hitTestPoint (currentClip.x, currentClip.y, true)) {}

    a match was found. Position the clip using the values of posArray:

    currentClip.x = posArray [index] .x;

    currentClip.y = there posArray [index];

    make not draggable:

    currentClip.removeEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

    currentClip.buttonMode = false;

    } else {}

    football match has not, so send the clip to the back where he began:

    currentClip.x = startX;

    currentClip.y = startY;

    }

    in this code, that I'm not the subject abruptly to its original position if he fell into a movieclip wrong (as we should have the availability of droping the drag square circle alse object) and then we should have a button to check if everything is correctly matched, if not after clicking another button 'correctitself', we should get the good objects droping on correct locations automatically

    Please help with any suggestions ASAP

    }

    assign your listener matchall checkAllMatchF and use button:

    var dragArray:Array = [square_word, circle_word, triangle_word];

    var matchArray:Array = [squareMatch, circleMatch, triangleMatch];

    var posArray:Array = [{x: 276, y: 207}, {x: 443, y: 207}, {x: 107, y: 207}];

    var currentClip:MovieClip;

    var startX:Number;

    var startY: number;

    for (var i: int = 0; i< dragarray.length;="" i++)="">

    dragArray [i] .buttonMode = true;

    dragArray [i] .addEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

    matchArray [i] .alpha = 0.2;

    }

    function item_onMouseDown(event:MouseEvent):void {}

    currentClip = MovieClip (event.currentTarget);

    startX = currentClip.x;

    startY = currentClip.y;

    addChild (currentClip); bring to front

    currentClip.startDrag ();

    stage.addEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);

    }

    function stage_onMouseUp(event:MouseEvent):void {}

    stage.removeEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);

    currentClip.stopDrag ();

    var int index = dragArray.indexOf (currentClip);

    var matchClip:MovieClip = MovieClip (matchArray [index]);

    If (matchClip.hitTestPoint (currentClip.x, currentClip.y, true)) {}

    a match was found. Position the clip using the values of posArray:

    currentClip.x = posArray [index] .x;

    currentClip.y = there posArray [index];

    make not draggable:

    currentClip.removeEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);

    currentClip.buttonMode = false;

    } else {}

    football match has not, so send the clip to the back where he began:

    currentClip.x = startX;

    currentClip.y = startY;

    }

    }

    function checkAllMatchF (): Boolean {}

    for (var i: int = 0; i<>

    If (dragArray [i] .x! = matchArray [i] .x | dragArray [i] there! = matchArray [i] there) {}

    Returns false;

    }

    }

    Returns true;

    }

  • Display collection ArrayCollection in a list and the ArrayCollection with Drag and Drop collection reorgnize

    I have an ArrayCollection collection created like this

    qaAC = new ArrayCollection();

    for (var i: int = 0; i < 10; ++ i) {}
    var o: Object = {question: ' what is "+ i +"? ", answer:" it's "+ i"};
    qaAC.addItem (o);
    }

    The ArrayCollection collection is an array of object that has properties "question" and "answer to" custimized.

    I want to put 'issues' in the ArrayCollection collection in a list. 'qaAC.question' does not return an array of questions for me.

    I have to extract the ArrayCollection collection to form a new String table, and use the new array as the dataProvider of the list of questions.

    Is there a way better and clean?

    My goal is to use a list to reorgnize an ArrayCollection collection that contains complex objects (not simple string) with Drag & Drop. Is this possible?

    Any suggestions?

    I put two lists in my example to show how the ArrayCollection collection could be displayed in two different ways. You don't have to have two lists if you do not need them.

    When you change the order of the list made with drag and drop, you change the order of the collection ArrayCollection qaAC, so all the controls that display the qaAC will also be updated to reflect the new order. You can test this in the example I posted earlier. Change the order in the list of question and you will see the order change also in the list of responses. This is because they are both bound to the same collection of ArrayCollection. If you want to behave independently, you need two separate ArrayCollections.

    Chris

  • Newbie request for assistance with several drag-and-drop &amp; multiple targets

    I know that this question has been asked a million times, but I get always very well the solution.  I know that the solution called for me the use of tables in a part of my code, but I have problems understanding how to implement it.  I use Flash CS 5.5 with AS3.

    I have a flash drag-and-drop file which is divided into 4 distinct zones on the stage.  On each box, there are 7 places, for 7 different "puzzle pieces".  The first two spaces on each quadrant have very a very specific order for the correct puzzle pieces, while the 5 additional places on each quadrant also have specific parts, but the order is not important.  I have included my code below for reference (note that I have not all instances, finished yet).

    Basically, in code that's been created, the following bodies have specific targets with specific command:

    D1_1_mc, D1_2_mc, D1_1_mc, D2_2_mc, D3_1_mc, D3_2_mc, D4_1_mc and D4_2_mc.

    All other instances, such as D1_3_mc, D2_3_mc, D2_4_mc, etc. have specific quadrants on which they need to fall, but what about the last 5 'spaces' in each quadrant, the order does not matter.  I know that I can continue to do what I do, but I would have preferred that the last 5 pieces on each quandrant do not have to be in a specific order.

    You can provide any assistance is greatly appreciated!

    var startX:Number;

    var startY: number;

    var counter: Number = 0;

    D1_1_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D1_1_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D1_2_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D1_2_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D1_3_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D1_3_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D2_1_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D2_1_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D2_2_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D2_2_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D2_3_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D2_3_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D2_4_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D2_4_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D3_1_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D3_1_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D3_2_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D3_2_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D3_3_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D3_3_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D4_1_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D4_1_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D4_2_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D4_2_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D4_3_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D4_3_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    D4_4_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    D4_4_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    function pickUp(event:MouseEvent):void {}

    event.target.startDrag (true);

    reply_txt. Text = "";

    event.target.parent.addChild (event.target);

    startX = event.target.x;

    startY = event.target.y;

    }

    function dropIt(event:MouseEvent):void {}

    event.target.stopDrag ();

    var myTargetName:String = "target_" + event.target.name;

    var myTarget:DisplayObject = getChildByName (myTargetName);

    If (event.target.dropTarget! = null & & event.target.dropTarget.parent == myTarget) {}

    reply_txt. Text = "Good Job!"

    event.target.removeEventListener (MouseEvent.MOUSE_DOWN, Pick-up);

    event.target.removeEventListener (MouseEvent.MOUSE_UP, dropIt);

    event.target.buttonMode = false;

    Event.Target.x = myTarget.x;

    Event.Target.y = myTarget.y;

    counter ++;

    } else {}

    reply_txt. Text = "Try Again!";

    Event.Target.x = startX;

    Event.Target.y = startY;

    }

    if(Counter == 5) {}

    reply_txt. Text = "congratulations, you did!"

    }

    }

    D1_1_mc.buttonMode = true;

    D1_2_mc.buttonMode = true;

    D1_3_mc.buttonMode = true;

    D2_1_mc.buttonMode = true;

    D2_2_mc.buttonMode = true;

    D2_3_mc.buttonMode = true;

    D2_4_mc.buttonMode = true;

    D3_1_mc.buttonMode = true;

    D3_2_mc.buttonMode = true;

    D3_2_mc.buttonMode = true;

    D4_1_mc.buttonMode = true;

    D4_2_mc.buttonMode = true;

    D4_3_mc.buttonMode = true;

    D4_4_mc.buttonMode = true;

    Since it seems to afew possible gaps in the code you showed, and what I offer myself in response to your questions, I spent a little time get a working model of what I guess you just using the three targets and the fall of four objects.  If you want, I can make the file available for you, but for now, here's the code that works...

    var startX:Number;
    var startY: number;
    var counter: Number = 0;

    target_D2_1_mc.allowed = new Array (D2_1_mc);
    target_D2_2_mc.allowed = new Array (D2_2_mc);
    target_D2_3_mc.allowed = new Array (D2_3_mc, D2_4_mc);

    D2_1_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);
    D2_1_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);
    D2_2_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);
    D2_2_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);
    D2_3_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);
    D2_3_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);
    D2_4_mc.addEventListener (MouseEvent.MOUSE_DOWN, Pick-up);
    D2_4_mc.addEventListener (MouseEvent.MOUSE_UP, dropIt);

    function pickUp(event:MouseEvent):void {}

    reply_txt. Text = "Good Luck."
    event.target.startDrag (true);
    event.target.parent.addChild (event.target);
    startX = event.target.x;
    startY = event.target.y;
    }

    function dropIt(event:MouseEvent):void {}

    event.target.stopDrag ();

    If (event.target.dropTarget! = null & MovieClip (event.target.dropTarget.parent).allowed.indexOf (event.target) >-1) {}
    reply_txt. Text = "Good Job!"
    event.target.removeEventListener (MouseEvent.MOUSE_DOWN, Pick-up);
    event.target.removeEventListener (MouseEvent.MOUSE_UP, dropIt);
    event.target.buttonMode = false;
    Event.Target.x = MovieClip (event.target.dropTarget.parent) .x;
    Event.Target.y = there MovieClip (event.target.dropTarget.parent);
    counter ++;
    } else {}
    reply_txt. Text = "Try Again!";
    Event.Target.x = startX;
    Event.Target.y = startY;
    }

    if(Counter == 5) {}
    reply_txt. Text = "congratulations, you did!"
    }
    }

    D2_1_mc.buttonMode = true;
    D2_2_mc.buttonMode = true;
    D2_3_mc.buttonMode = true;
    D2_4_mc.buttonMode = true;

  • How to drag and drop multiple movieclips at the same time

    Hello world

    I'm a new actonscript 3 and adobe flash CC user and I am building an application but I have been stuck for several days. I have looked everywhere and tried everything I could think of, but I can't yet find a solution to my problem that I thought were pretty basic.

    Basically, let's say I have a rectangle and a circle on the stage. Once I did of the movieclips and assigned an instance name to each of them, I want to be able to perform a drag and drop the Rectangle so that both the rectangle and the circle become movable at the same time.

    For now, I have a mouse down events listener associated with the instance of rectangle, a method startDrag assigned to the rectangle instance and another assigned to the circle. But in this configuration, when I click on and drag the rectangle, only the circle is mobile (only the last line in the code is taken into account).

    I don't know if what I'm trying to achieve is feasible, but any help will be greatly appreciated, thank you!

    The startDrag() method can only work for one object at a time, so in your case the Treaty the last of them, designated the task.  This approach is to temporarily to plant the two objects in a container and then drag the container.

    rectangle.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);  When I click on the rectangle

    var dragMC:MovieClip = new MovieClip();
    addChild (dragMC);

    function fl_ClickToDrag(event:MouseEvent):void

    {
    dragMC.addChild (rectangle);        move objects in the container
    dragMC.addChild (circle);
    dragMC.startDrag ();
    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop); When I release the mouse button

    function fl_ReleaseToDrop(event:MouseEvent):void

    {
    dragMC.stopDrag ();
    Rectangle.x += dragMC.x;         Adjust the positions of the objects to their new location
    Rectangle.y += dragMC.y;
    Circle.x += dragMC.x;
    Circle.y += dragMC.y
    addChild (rectangle);                 move back to the scene objects
    addChild (circle);
    dragMC.x = dragMC.y = 0;       reset the benchmark for the dragMC
    }

    All this stuff of repositioning in the Drop function is necessary because when you drag the container, the positions of the content are still on their original coordinates inside the container.  So when you drop them they will resume their x / y positions in their new parent, meaning they go back where they were.  Reposition them where they have been trained to take into account the change in the position of the dragMC.

  • ALT + tab no longer works with drag-and-drop

    I bought a new computer Samsung with Windows 8, two weeks ago. On my old computer, I could choose a file in a folder, then alt - tab to another folder and then drop the selected file. Now, every time I select a file and use alt - tab, the file automatically becomes deselected.

    This never happened to me in my previous versions of Windows.

    To be clear: my keyboard and touch pad working perfectly fine. It is a problem of Windows when you use drag-and - drop jointly with alt - tab.

    Hello Boston,

    This feature is also available in Windows 8. You must select a copy of the file and click alt + tab and select the folder where the file should be moved or pasted.

    If this does not work on your computer, you can try to follow the link below and create a new user account and see if that helps. To create a user account follow this link:

    Create the user account

    I hope this helps. Otherwise, feel free to write us again and we will be happy to help you.

    Thank you

  • FlashBuilder - how to move the code with drag and drop

    Guys, I must be stupid. Each IDE I worked in allows me to highlight one or more lines of code, and then, when I mouse over the highlighted lines, updates of the cursor to indicate that I can now drag the code, and it moves when I click and drag.

    FlashBuilder (burrito) does not seem to exhibit this feature, but if I hold down the CTRL I do not copy the code via drag and drop.

    There has been one or two occasions where the drag-and - déposer worked, but I can't understand, or reproduce these conditions.

    Can anyone help?

    Thank you

    T

    It should work in Flash Builder, but you are right, that feedback cursor is not very good because it is not updated to show that any sort of slider. Try selecting the text, then click and hold for about a second before you drag it to a new location. If it still does not work for you it must be another problem. Make sure that in preferences, general-> editors-> text editors "Enable drag and drop of text" is turned on.

  • The show with drag and drop in Captivate 9

    Hello

    I am creating a drag and drop interactivity 9 Captivate. In step 3, when I had to drag the objects from the source to the drop target, all objects in the screen were locked. I couldn't click as well as she was listed on the timeline . Please suggest.

    Using the wizard or the D & D Panel? Is this normal or a receptive

    of the project? You are on Mac or Win.

    For the wizard: .you should see a center point on each source of drag.

    You must drag a line from this central point to the drop target. You did

    create a type?

  • Need help with drag and drop

    IM really new to this program as a

    day new hehe and I need help. im making a game quiz and your supposed

    ED to score in the hoop with a circle.  I have the

    codes for the drag and drop for the circle, but I need help with the collision between the Hoop and the ball, I want to go to the image next or gotoandPlay when the ball touches the ring. HELP PLEASE

    You should not attach code to objects.  and you can be able to happen by using a loop.

    Start by removing all the code the suggested by maqro (i.e. as3) and by removing all the code attached to objects.

    use:

    {yourobject.onPress = function ()}

    this.startDrag ();

    }

    {yourobject.onRelease = yourobject.onReleaseOutside = function ()}

    this.stopDrag ();

    {if (this.) HitTest (whatever))}

    do something

    }

    }

  • A small problem with Drag &amp; amp; Drop

    Hello!!

    I need to drag an external image on an IMAGE control.
    This is the command:

    "< mx:Image id ="myImg"source =" {File.desktopDirectory.nativePath + "test.png"} "x ="392"y ="267"height ="140"width ="150" dragDrop =" DropHandler (event) " dragEnter ="DragManager.acceptDragDrop (event.currentTarget as Image); » / >

    the 1st problem is that the dragDrop event is not called...
    dragEnter is...

    dragExit works... dragOver too...
    but the dragDrop and dragComplete event not...
    so... I can't try to find a solution for my main problem: get the path to an external image slipped...

    Any help?
    all the tutorial I've read talk about dragging an object in a flex container to another container flex...

    Bye bye... and thank you!

    Quote:
    Posted by: 123qweads
    Image has no option of dropEnabled ^ _ ^.

    Well, it sounds a Bell then? :))

    If the control does not feature move it is useless just to wait that little bit of magic will happen and he will somehow begin to accept drag and drop.

    So what you have to do - create handlers for the mouseOver, mouseMove and mouseUp/down and rip the drop from the mouseUp event.
    See you soon!

  • Help with Drag and Drop text

    I am trying to create a series of text objects that I can drag and drop on the screen. I'm trying to text fields in a movieClip container from the Drag and Drop will not work on text fields. When I do that, Flash still sees the objects as fields of text rather than the video clips, and I get the following error.

    ReferenceError: Error #1069: property not found startDrag on flash.text.TextField and there is no default value.
    at chris_fla::MainTimeline/startDragging()

    I'm a newbie to this. What I am doing wrong? Thank you!

    Russ

    Use currentTarget instead of the target.

  • Closed: ADF tree with Drag and Drop

    Hi all

    How to implement drag and drop functionality in ADF tree where we manage to reorganize the tree.
    Is this possible? any material / sample for the same thing.

    Thank you.

    Chris Muir has bloged about this 't-fit-all.blogspot.com/2009/09/jdev-11gr1-aftree-mashup-using.html http://one-size-doesn
    and AMIS has this http://technology.amis.nl/blog/3302/dropping-trees

    Timo

Maybe you are looking for