Add component snap with Drag/Drop (involving classes)

I am little confused where to add a wink feature to my drag and drop puzzle I created. I use two classes (DragGame and DragDrop) move of twelve pieces. I want the pieces to snap into place once they are trained near their contact information. I guess that this must be done in my DragDrop.as file.

package

{

import flash.display.MovieClip;

import flash.events.MouseEvent;

SerializableAttribute public class extends MovieClip DragDrop

{

public void DragDrop()

{

this.buttonMode = true;

this.addEventListener (MouseEvent.MOUSE_DOWN, dragPiece);

this.addEventListener (MouseEvent.MOUSE_UP, dropPiece);

}

private void dragPiece(event:MouseEvent):void

{

this.startDrag ();

}

private void dropPiece(event:MouseEvent):void

{

this.stopDrag ();

}

}

}

I tried to add a function setProperty under function stopDrag for each piece, but it does not save: example

setProperty ("p12_p", _x, "222.22") and setProperty ("p12_p", FLF, "222.22").

p12_p is the piece of the puzzle that I'm trying to align this coordinate. I'm sorry I'm really new with classes, normally, I would do that how I'm used to all right in the fla file itself.

What do you think goes in the direction of...

private void dropPiece(event:MouseEvent):void

{

this.stopDrag ();

if(Event.currentTarget.DropTarget == SomeObject) {}

event.currentTarget.x = someObject.x;

event.currentTarget.y = someObject.y

}

}

There may be some adjustments and you must replace "SomeObject" "" "by a real name (or target) object instance, but this is the general approach of what you need to do."

Usually the dropTarget is actually the child of the object you plan to be the actual target... This is the thing inside the object... so what you need to do is then to target the parent to see if it is the objective intended, as in... someObject.parent

Tags: Adobe Animate

Similar Questions

  • TDM excel 2010 component snap with limitation of 65536 lines.

    Hello

    I installed TDM excel 2010 component snap and have excel 2010 (32-bit version) on my laptop.

    When I open a file PDM with 300000 lines using excel importer of PDM, it will automatically start the excel. But it will display a dialog box saying that the number of rows exceeds the limitation of the program (65536). It confuses me because excel 2010 is supposed to be able to open the data file more than 1 million rows.

    The add-in works great with any TDMS file within the limit of 65536 lines.

    Any thought or idea, let me know, thanks.

    Marco Yu

    Mechatronics Engineer

    BMT WBM

    Hi Marco,.

    CAR refers to the application of Corrective Action. OR use the bug tracking system.

    For this request, we have already begun to investigate. Thanks for reporting the issue!

    Best regards

    Mavis

  • Quiz questions mixed with Drag & Drops - Quiz review issue

    Hello

    Is there a way to show the right answers for a drag and drop exercise if the learner chooses wrong?  My problem is that I have an evaluation with different types of questions (Multiple, Matching and Drag & Drop choice questions).  When the test ends and the click of the learner "Review Quiz", they can view their errors on Multiple choice and matching questions but not answers for fiscal drag-and - d├⌐poser.

    I tried to add a failure slide so that when the learner chooses bad, they jump to a slide of failure which shows the good answers/layout for drag / move.  The problem I have is once that the learner reviews the results of question Multiple choice and matching, there is no next button on the last slide of the question, if the review stops right in the middle.

    I was hoping there is a way to let the learner to make two attempts to the drag / move, and once the learner has used all attempts and is always incorrect, the learner can click a button to auto-submit to see the D & D response.

    I use 8 Captivate and my ratings are based on the web so I'm not using an LMS System.

    Thank you

    Jeff

    Interaction in D & D, even if configured as a question slide, has still not all of the features of the normal question slides. If I find a solution to your problem, will post as soon as POSSIBLE.

  • Happy page with drag & drop

    I have a content of the page that contains drag - move (built with Adobe Edge). It is sometimes difficult to interact with drag - move due to the feature page of the striking folio to swipe. What are workarounds for this problem?

    Thank you
    Patrick

    Implementation e.preventDefault () on the touchStart event in my edge piece animate the round is played!

  • AE CS4 - 9.0.3 - seeds of GUI refreshing with drag & drop - Win 7 x 64

    Hello

    After you install AE 9.0.3 on Win 7 x 64, I'm running in GUI glitches when drag and drop items in the graphical interface that is not correctly updated. For example, when I reorganize the effects in the control panel of effects or when I drag / drop a preset on the teamline. The GUI is not refreshed to cleanly, leaving upleasant "trails" that show the motion I did. When I release the mouse button, some panels get a complete refresh (for example the panels of timelines and effects controls), while the effects and parameters predefined remains full of garbage.


    It's never presented before. Other applications, such as first CS4 do not appear this problem.

    NVIDIA GeForce 9400 GT, last pilot 258.96

    Thank you for the support,

    Jean-Sébastien Monzani

    ae903.jpg

    The solution is to run After Effects on Windows 7 using the Windows Vista compatibility mode. You can set the by right-clicking on the application After Effects CS4 shortcut, selecting Properties and then choosing Windows Vista (or one of the entries for a Service Pack for Vista) from the menu "run this program in compatibility mode for" on the Compatibility tab. As follows:

  • 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

  • Drag / drop does not work in external SWF?

    Hi all

    I am currently a TA for a Flash course at my school.  We are using AS 2.0 and external SWF.

    I think it could be very simple to remedy.  Well, at least I hope!

    A student is wrong with drag & drop functionality when used in an external SWF.  In fact, in our drag & drop section, we have a sheet of paper ('book' MC) and an object drag us in it ('object' MC).  When the object is released in the paper area, we go to frame 2 of the 'paper' MC, who therefore has an animation.

    It works very fine and dandy in the said drag & drop section, but once the section drag & drop is loaded into our main SWF via a space reserved MC, the feature drag - move no longer works.

    Here's the URL for the section drag & drop by itself:

    http://www.phayzed.com/Flashkit/drag_for_animation.swf

    and here's the URL for the main SWF, that loads the drag & drop SWF into a movieclip and forced to work incorrectly:

    http://www.phayzed.com/Flashkit/main.swf

    Here is the code on the draggable object ("object" MC):

    on (press) {
            startDrag (this, true);
    }
    on (release) {
            stopDrag ();
            if (this._droptarget == "/paper") {
                    _parent.paper.gotoAndStop(2);
                    _parent.object._visible=false;
    ;
            }
    }
    
    
    

    If we need more info, I'm ready to download the two FLA files.   Although, something tells me it's a simple problem to solve.

    For any help, thank you very much!

    See you soon
    T

    with as2, you need to convert that code to archaic as1:

    on (press) {
            startDrag (this, true);
    }
    on (release) {
            stopDrag ();
            if (eval(this._droptarget) == _parent.paper) {
                    _parent.paper.gotoAndStop(2);
                    _parent.object._visible=false;
    ;
            }
    }
    
    
    
  • Code of the Drag &amp; Drop

    Hello. I'm french (so excuse me for my language).

    I am a beginner in flex and I would like to have information.

    In an application that I do, I want to use the datagrid control. I also use a trash can. The data grid lines are not removed directly: they are send to the trash.

    I also want to restore the data to the trash. I know that I can use this transfer with drag & drop, but I would use a button too.

    For example, a "Restore" button will send the first row selected in the datagrid control. And deleted the datagrid button will send the line to the trash.

    You have an idea on the code I should use?

    Thank you very much.

    Alexis.

    something like that?

    
    
    
        
            
            
            
            
            
            
            
            
            
            
        
    
        
            
        
    
        
            
                
            
        
    
        
            
                
                    
                        
                            
                                
                                
                            
                        
                    
                
            
        
    
    
  • 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);
    }
    
  • using the FC command with the GUI drag & drop

    In Windows 95 and 98, it was possible to make a shortcut to the "CF" MS-DOS command on the desktop, and then compare two files by drag & dropping them on the shortcut.

    However, starting from Windows XP, while this still TECHNICALLY works, the MS-DOS window (I do not remember what to call other than "command prompt window", so bear with me) will close immediately upon expiration of the program, making it impossible to read the results, especially if it is "no differences encountered".

    I remember that there was no decent way to solve this problem in XP, but is there a solution to Vista or 7? Typing long file names can be heavy, and even by using copy and paste is tedious compared to the ease, I remember not on Windows 9 X.

    Oh, I just had a thought when you think of batch files. I tried to add a pause at the end command. That seemed to work. It has been long since I made a batch file that needed the pause command. I don't know why I thought using a batch file with a command to break a decade ago.

    Oh and thanks for the link explaining the differences in the manufacture of the batch files. I learned how to 3.30 in 1990 for MS-DOS batch files and never really learned anything new other than the fact that I could use drag-n - drop in Windows 95.

    Is there something else that I could learn a few new tricks that have been introduced since MS-DOS 3.30? I _might_ have read books for MS-DOS 4 or 5 at the time, because there weren't really that many differences. The only different things I knew were the dosshell in MS-DOS 4, Edit & QBASIC in MS-DOS 5 and extended external help of 6.2.2 MS-DOS command which was similar (although I didn't know it until the end of the 1990s) for Unix man pages. Oh, and in one of these versions, they also did better? parameter help messages.

  • Drag &amp; Drop of Simulation with catalyst?

    Hi all

    I just want to know if there is a way to simulate a direct manipulation as Drag and Drop with

    Catalyst?

    Thks

    K.

    Hey K,

    The short story, so no, do not support us drag & drop simulation of catalyst.

    It's something you'd have to add in Flash Builder.

    There is more information on getting from drag & drop support here: http://www.adobe.com/devnet/flex/quickstart/adding_drag_and_drop/

    Please do not hesitate to develop and add details about how you want to see drag & drop work within catalyst.

    Thanks and let me know if you have any other questions.

    Tara

  • Qosmio x 870-Drag & drop with alt - tab is not possible using the touch pad

    Hi all

    I have a problem with my Qosmio x 870 and drivers touchpad Synaptics on Win7 64 bit.
    They do not drag-and - drop between applications.
    As soon as I press Alt - Tab, all by dragging a file to switch to one another application, dragging instantly stops.

    I use official & later (15.3.41.7) drivers of Toshiba touchpad http://goo.gl/pKHAI here

    I tried to install the generic Synaptics drivers and they do not have such a problem.
    With them, everything works very well with drag and drop.
    However, their implementation of two fingers to scroll is really buggy and more than half the time it does not work so I can't use them.

    Does anyone know if this bug and when?

    Any help? Thank you!

    Hello

    Maybe you should check the settings in
    Control Panel-> mouse-> advanced-> Advanced Settings tab

    There is an area called operations during key entry
    Make sure that the options are not checked.

    You said you tried the driver generic Synaptics you chose this one:
    http://www.Synaptics.com/resources/drivers

  • Interference with the drag &amp; drop on MC ListBox

    LV 2010, Win 7

    I have a Drag and Drop interface, where the user drags elements from one part of the window on a multicolumn ListBox, in order to build a result of type worksheet.

    The format they're building is known and that they can apply to multiple data files in the future.

    They can also drag rows around to rearrange their and columns around too, once they are placed.

    It's everything works fine, EXCEPT:

    If the text in a given cell listbox is longer than the width of the cell, the text is partially hidden.  It is very good.

    If you move the mouse over the cell, something like a 'tip-band' opens and displays the full text.  It is very good.

    BUT

    This band of advanced interfere with dragging something.  When you click, you click on the BAND, not the list box.

    As a result, the DEPARTURE of DRAG? event never gets called and then you can not drag.

    You can see in this JING :

    I drag a few items on the OK sheet.

    I can drag down TIME line and put it somewhere else.

    But I can't drag the item with the band on this subject.

    Notice that I CAN drag this line, by entering the number which has no band that covers. (My code allows you to drag a line by clicking anywhere on the line, except for the symbol).

    If you try hard you can move the mouse on a cell, click on before the band gets up and do it very well.

    Thus, the code works fine.

    I checked do DRAG from? is not called, if there is a band under the mouse.

    What can I do about it?  I have not found a way to disable this band. Indeed, it is useful.

    But I don't think that is a command I can get events from.

    So I have no way of knowing if she is released or not.


  • Drag &amp; Drop problem with Workstation 9

    Hi I'm under WorkStation 9.0.1 build-894247 on a 64-bit Windows 8 host.

    I'm having a problem with drag-and - drop files between the host and the guest.

    Here's what I found;

    • If I run that high Workstation (IE "run as Administrator") then I can only drag files from the client to the host. Drag files between the host and the guest, I simply "cannot delete here" mouse cursor.
    • If I'm not running workstation high so I can just drag files between the host and the guest. When you drag the client files the mouse cursor stops at the border of the comment window.

    I have all the options set in the settings of the computer prompted virtual isolation.

    I get the same results with various Windows OS such as Linux clients.

    I'd like to at least know if someone else has this problem.

    (Performance of the latest tools 9.2.2)

    I answer to my orig post as Workstation 10 fixed drag & drop the issue.

    I had a client silently stop accepting drops well and had to reboot to get things working again - but I'll keep for a new discussion if he continues to be...

  • 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

Maybe you are looking for

  • Satellite M200 - wireless XP driver does not work

    Hello I downgrade to Windows XP to my laptop Toshiba Satellite M200 coz Vista was slow, but now my wireless drivers do not work.I tried many drivers but the result is the same. Please suggest a solution. Thank you very much.

  • IN REF Lenovo V570-1066XB2 i5/6ACCS wireless

    IN REF Lenovo V570-1066XB2 i5/6ACCS 1. I've upgraded to Windows 8 November 2012. My wireless worked after upgrade. 2. the June 2013, Windows 8 auto update Intel 3000 graphics file. 3. 2 days to type in the command prompt and multiply half hour restor

  • on the Welcome screen... How can I change the default windows live address?

    on the Welcome screen... How can I change the default windows live address?

  • WRT1900ACS

    I come from Hong Kong, want to buy a WRT1900ACS wireless router. This product is available in the United States only, Amazon it is not delivered to Hong Kong, eBay does not have it.  Is anyone aware of any seller that it will be available internation

  • Error trying to build app

    Hello I am developing an app for blackberry and so downloaded the momentics ide with the blackberry 10 Simulator. However, when I create a new application (only the model of "hello world" single) and try to build, I get the following error: make [1]: