Newbie request for assistance with several drag-and-drop & 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;

Tags: Adobe Animate

Similar Questions

  • 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);
    }
    
  • Several Drag and Drop, several targets. CS5

    Hello:

    I do a Multiple of Drag and Drop in several objectives educational puzzle for child 6-7 years trying to teach them a little on which plants grow in environments in the country. So I have a map of the Mexico divided into 3 different areas: desert, forest and tropic and 6 different plants (3 different groups: cactus, pine and tropical flowers, 2 of each) scattered across the stage and around the map. The goal is for children to put plants in the box to the right and then click on "check" button, which triggers a validation process. Each video clip of the plant has 2 frames with a stop(); action on all: the graph of the plant extends on both images and the second picture has a red sign error graphic that indicates an error occurred (if this is the case). Then the validation process triggered by the "check" button is supposed to move the playback cursor in each placed wrongly move clip factory for the second image to show what plants are displaced and move the playhead of the main timeline to a picture that contains a "Please try again" text and a button "restart Puzzle." If the answers are good, an animation plays saying it was VERY WELL DONE! .

    I searched the Internet for some tutorials and found a file which is pretty close to what I need. I tried to adapt the code to my puzzle but failed miserably. The file is here if you want to check (scroll to the bottom of the page, it is called Soldier.fla). I'm not sticking the code here because it is VERY long, but I will if necessary. If you want that I download the files somewhere else and link them here, I will. If you need me to send them, I'll be happy.

    Here is the structure and instance names in my file:

    Departure:

    -Intro animation

    Map:

    -3 video clips: target_1, target_2 and target_3.

    -Each movie clip has two executives with a stop(); action on each.

    -Each movie clip has a frame-by-frame with a color change to show when a clip of plant fell on her.

    Plants:

    -6 video clips: drag_1, drag_2, drag_3, drag_4, drag_5 and drag_6.

    -Each movie clip has two executives with a stop(); action on each.

    -Each video clip has an invisible button in its background layer called dragbutton1 to dragbutton6 respectively.

    -In the second frame of each clip, I placed a sign of error to be displayed when the boy dropped the clip in the wrong target.

    Placement:

    -video clips drag_1 and drag_3 must be embedded in the target_1.

    -video clips drag_2 and drag_4 must be embedded in the target_2.

    -video clips drag_5 and drag_6 must be embedded in the target_3.

    Buttons:

    -Puzzle AutoScan: main playhead moves to an image named 'play '. It shows after the Intro animation.

    -Check the button: Validation process. If there is any mistakes sends the playhead to main to a named 'wrong' image (here is the text of "Please try" again). If there is no error, sends the playhead to main to a framework called 'good' where begins the animation "Very well done". It shows when start the puzzle.

    -Restart the Puzzle button: moves the main playback head to frame of 'Play '. It shows when start the puzzle.

    -Start button: just restarts. It shows after "Very well done" animation.

    Phew, it was long!

    Now, I'm not a programmer, I'm a designer. I can do buttons and other small things very simplistic but it's just out of my League. Programmers do things my office like PHP (Wordpress, Joomla), a few JS and things like that, but they don't do any ActionScript. They are trying to help but let drop the ball and I tried to understand this since Friday (I took this as a challenge and he lost). The customer wants in AS2, but if you can help me in AS3, screw the customer!

    If one of you can help me with the code, or point me to the right place, I'll be in debt to you. Forever.

    Thank you very much.

    This is a typo and should be:

    var dragA:Array = [drag_1, drag_2, drag_3, drag_4, drag_5, drag_6];

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

    [i] dragA dragA [i] ._x = .startX;

    [i] dragA .startY dragA [i] ._y =

    If (i == 0 |) I == 2) {}

    dragA [i] .target = target_1;

    } else if (i == 1 |) I == 3) {}

    Dropped [i] .target = target_2;

    } else {}

    Dropped [i] .target = target_3;

    }

    {dragA [i] .onPress = function ()}

    this.startDrag ();

    }

    dragA [i] .onRelease = function () {}

    this.stopDrag ();

    checkTarget (this);

    }

    }

    function checkTarget(drag_mc:MovieClip):Void {}

    {if (drag_mc. HitTest (drag_mc. Target))}

    feedback. Text = "done Well! »

    } else {}

    feedback. Text = "Missed";

    drag_mc._x = drag_mc.startX;

    drag_mc._y = drag_mc.startY;

    }

  • Why creates shortcuts for Moving files when drag and drop the folder or file in another folder?

    I am using Windows XP SP3, just before I drag and drop the file into another folder in my windows explore. Suddenly, he is creating shortcuts for moving file. I'm not able to move the file by drag / move the mouse, it is possible that by cutting and Paste(Ctrl+X) using the keyboard. Why?

    Maybe your 'Alt' key is stuck.
    See exchanging the keyboard with another makes all the difference.

    HTH,
    JW

  • How to prepare list for garbage collection after drag and drop operation

    Hi all

    I have a view in a mobile application that contains a list with the help of drag / move. The problem I encounter is that the NativeDragManagerImpl maintains a reference to this list in its _dragInitiator and _relatedObject properties. It is not a memory leak by - say, because the reference will be replaced the next time make drag and drop is used, however, my view that preclude any garbage collection, causing an unacceptable peak memory.

    Here is an example which illustrates the problem (app default AIR using Flex 4.5.1):

    Main.MXML

    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:local="*"
                                                         xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" width="800"
                                                         height="600">
    
    
              <fx:Script>
                        <![CDATA[
                                  protected function start_clickHandler(event:MouseEvent):void
                                  {
                                            var element:ListGroup = new ListGroup();
                                            this.panel.addElement(element);
                                  }
    
                                  protected function stop_clickHandler(event:MouseEvent):void
                                  {
                                            this.panel.removeAllElements();
                                  }
                        ]]>
              </fx:Script>
    
    
              <s:Panel id="panel" top="100" left="100" bottom="100" right="100" title="Drag Drop Test">
                        <s:controlBarContent>
                                  <s:Button label="Start" click="start_clickHandler(event)" />
                                  <s:Button label="Clear" click="stop_clickHandler(event)" />
                        </s:controlBarContent>
              </s:Panel>
    
    
    </s:WindowedApplication>
    
    

    ListGroup.mxml

    <?xml version="1.0" encoding="utf-8"?>
    <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"
                         xmlns:s="library://ns.adobe.com/flex/spark" width="100%" height="100%">
              <s:layout>
                        <s:HorizontalLayout />
              </s:layout>
              <s:List id="sourceList" width="100%" height="100%" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
                        <s:dataProvider>
                                  <s:ArrayCollection>
                                            <fx:String>Item 1</fx:String>
                                            <fx:String>Item 2</fx:String>
                                            <fx:String>Item 3</fx:String>
                                            <fx:String>Item 4</fx:String>
                                  </s:ArrayCollection>
                        </s:dataProvider>
              </s:List>
              <s:List id="targetList" width="100%" height="100%" dragEnabled="true" dragMoveEnabled="true" dropEnabled="true">
              </s:List>
    </s:Group>
    
    

    If you drag items to the list on the right, there is always at least one instance of ListGroup stuck in memory for the duration of execution (as seen in the profiler).

    Is there a way to perform cleanup on the DragManager (or in fact the underlying DragManagerImpl) upward to a time of my choosing? Thoughts or ideas will be greatly appreciated!

    Thanks a lot for your time!

    I think I'd be monkey-patch NativeDragManagerImpl.  And create a bug report.

  • Several drag and drop - when the correct triggers something

    I am very new to Flash, so I hope that what I try to do is not beyond my capabilities.

    I want to create a game in which you have to drag and drop three correct items for a target area. When the three correct items are removed, the game should move forward to the next part.

    I tried to get help on this, but I don't know what exactly I should look for (IE what terms, keywords).

    Any help would be much appreciated, even if it's just to tell me the terms Flash I need to point me in the direction of assistance.

    Thank you!

    Here are a few terms to look on...

    startDrag()

    stopDrag()

    _droptarget

    hitTest()

    If you search Google using terms such as "StartDrag AS2 tutorial", you may be able to find something that describes everything what you want for your design

  • Help with a Drag and Drop problem

    I design a simple drag and drop the game, ranking but I had several objects and targets, for example square shaped object cannot go to target square shape, but when I have 2 or more place then the square2, carre3 can not go to square target! I used the code as belo

    var objectoriginalX:Number;
    var objectoriginalY:Number;
    var counter: Number = 0;

    triangle_mc.buttonMode = true;
    triangle_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    triangle_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    circle_mc.buttonMode = true;
    circle_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    circle_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square_mc.buttonMode = true;
    square_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square2_mc.buttonMode = true;
    square2_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square2_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    square3_mc.buttonMode = true;
    square3_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    square3_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    star_mc.buttonMode = true;
    star_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    star_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    poly_mc.buttonMode = true;
    poly_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    poly_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    function pickupObject(event:MouseEvent):void {}
    event.target.startDrag (true);
    event.target.parent.addChild (event.target);
    objectoriginalX = event.target.x;
    objectoriginalY = event.target.y;
    }
    function dropObject(event:MouseEvent):void {}
    event.target.stopDrag ();
    var matchingTargetName:String = "target" + event.target.name;
    var matchingTarget:DisplayObject = getChildByName (matchingTargetName);
    If (event.target.dropTarget! = null & & event.target.dropTarget.parent == matchingTarget) {}
    reply_txt. Text = "Good Job!"
    event.target.removeEventListener (MouseEvent.MOUSE_DOWN, pickupObject);
    event.target.removeEventListener (MouseEvent.MOUSE_UP, dropObject);
    event.target.buttonMode = false;
    Event.Target.x = matchingTarget.x;
    Event.Target.y = matchingTarget.y;
    counter ++;
    score_txt. Text = String (counter);

    } else {}
    reply_txt. Text = "Try Again!";
    Event.Target.x = objectoriginalX;
    Event.Target.y = objectoriginalY;
    -counter;
    score_txt. Text = String (counter);
    }
    }

    Thank you very much for your help!

    An easy way to handle this is to assign a variable for each target that will tell you whether or not it is still a usable lens... Let's say you name "usable", it starts as a true for each target value.  Once a target is used you change the value of this variable to false.  You use this variable as abother test in your conditional.  Something like...

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

    event.target.dropTarget.useable = false;

  • 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 + drag and drop multiple files

    Hello.

    I have several files QT in After effects, I want to easily exchange with the OpenEXR files.

    Is it possible to do this with several files already imported into Adobe AE?

    It seems the ALT + dragdrop only works for one file at a time for me. Is it just a sollution file?

    I'm on Adobe after effects CC (last version by date). Running Windows 7.

    Thank you.

    Anton

    Yes, ALt + move only works with a single selection. Whatever it is would require more script. for future reference, you can also set the QT files as substitutes and point the originals on the EXR sequences. You may just create some dummy EXRs when put you it in place, so AE does not give you errors.

    Mylenium

  • How to drag and drop multiple objects in a mask?

    nightvision.jpg

    I worked on a flash Simulator to show what our night vision product would look like in the dark.  I managed in the implementation with the following code below.  However, I can't add a picture "crosshairs" (or symbol) to the movable mask to make it work.  Can someone help me with the code?  I looked for hours on the internet and I can't make it work.  I'm new to Flash, but begins to learn as much as I can.

    ActionScript 3:

    img_nv. Mask = mask_mc;

    mask_mc.buttonMode = true;

    mask_mc.addEventListener (MouseEvent.MOUSE_DOWN, dF);

    stage.addEventListener (MouseEvent.MOUSE_UP, dropF);

    function dF(event:MouseEvent):void {}

    mask_mc.StartDrag ();

    }

    function dropF(event:MouseEvent):void {}

    mask_mc.stopDrag ();

    }

    Use a loop (such as enterframe) and update the position of the reticle to match the position of mask_mc.

    mg_nv. Mask = mask_mc;

    mask_mc.buttonMode = true;

    for example, if you add reticle_mc to the stage in the authoring environment

    removeChild (reticle_mc);

    mask_mc.addEventListener (MouseEvent.MOUSE_DOWN, dF);

    stage.addEventListener (MouseEvent.MOUSE_UP, dropF);

    function dF(event:MouseEvent):void {}

    addChild (reticle_mc);

    this.addEventListener (Event.ENTER_FRAME, reticleF);

    mask_mc.StartDrag ();

    }

    function dropF(event:MouseEvent):void {}

    removeChild (reticle_mc);

    this.removeEventListener (Event.ENTER_FRAME, reticleF);

    mask_mc.stopDrag ();

    }

    function reticleF(e:Event):void {}

    reticle_mc.x = mask_mc.x;  assuming that they both have the same reg points (as the Center)

    reticle_mc.y = mask_mc.y;

    }

  • Request for assistance with the importation of crude oil

    I get a program error message when you import a raw (.orf) file in Adobe Photoshop Elements 10.

    Also after the update of all the adobe programs.

    The raw file is generated by my camera Olympus E - M10 mark II

    Please give me a clue how to solve this problem.

    Piet

    Your camera is more recent than your software for many years.  To open the ORF of the EM10II you need ACR plugin 9.2 which host needs a PSE14 or newer.  You can buy 14 items here: http://www.adobe.com/products/catalog/software.html

    You can also use the free DNG Converter to convert a FOLDER of raw files to DNG and these DNG is open in the old software.  You can get the DNG Converter here: http://www.adobe.com/downloads/updates/

  • request for assistance with rman cloning script

    Hello


    Oracle 10.2.0.4, Win 2008

    I take a full backup using rman using the script below.

    Run {}

    allocate channel d1 type disk;

    backup filesperset 5

    format 'R:\backup\df_t%t_s%s_p%p '.

    database;

    SQL 'alter system archive log current';

    backup format 'R:\backup\al_t%t_s%s_p%p' (archivelog all delete input);

    cross-checking of backup;

    remove obsolete;

    output channel d1;

    }

    Inorder to clone the database live everyday on machine clone, I copy the backup files of auxiliary machine to the same directory as the script traore Live.

    My question is:

    How to restore the database from the beginning through script. I mean

    They invite cmd, set ORACLE_SID and ORACLE_HOME

    Start the database in nomount

    How to automatically include the number of scn in the restore script.


    Please guide me.


    Thank you

    In machine clone do you have the same directory Live machine.
    If the directory structure is different for the data files and log files and then in file pfile
    you keep
    DB_FILE_NAME_CONVERT = "string1", "string2".
    log_file_name_convert = "string1", "string2".
    When channel 1 is the direct model of machine datafile, channel 2 is the clone machine model
    startup nomount machine clone

    (1) rman target catalog auxiliary.
    race 2)
    {
    allocate auxiliary channels ch1 type or
    allocate channel ch2 type or
    until the SNA <> or climbs up to the hour<>
    duplicate target database standby
    }

    Published by: renee_mathieu on July 19, 2012 07:51

    Published by: renee_mathieu on July 19, 2012 07:51

  • With reagent drag and drop cursor misalignment.

    Hello!

    I use jquery ui to make movable and capable of receiving items. I also use the new feature of reactive (thanks!) across the entire animation.

    However, when I try to click on my moveable objects, the cursor and the element are disrupt. It seems that when the cursor is over x, y of the draggable element is x ^ 2, y ^ 2, the slider gets to the top left, plus the distance between the droppable object and the cursor.

    I can't even let go of the cursor capable of receiving areas and the movable object behaves as he dropped it, even if it appears in the wrong position.

    I read something on the adjustment of the alignment of the scene, but that has not worked. See below.

    http://forums.Adobe.com/message/4817827#4817827

    All the tips are greatly appreciated. A code that I can put directly into the compositionReady stadium would be excellent.

    Thank you very much

    Heureka! It is possible, I found a solution...

    I take the width of the window and make a report with the width of the stage variable... The stageratio then gets multiplied with the details... When resizing the window, variables are recalculated...  Here's a working example:

    http://sandbox.junglecrowd.org/responsive_works/publish/Web/responsive.html

    Here is the code:

    CompositionReady

    SYM.xycompensation = function() {}

    var point = sym.$('Stage');

    var parent = sym.$('Stage').parent ();

    var parentWidth = stage.parent () .width ();

    var stageWidth = stage.width ();

    SYM.scaleratio = stageWidth/parentWidth;

    };

    SYM.xycompensation ();

    $(window) .one ("Resize", function() {}

    SYM.xycompensation ();

    });

    sym.infoLabel = function() {}

    var position = sym.$("box").show ();

    position2 var = sym.$("text").show ();

    position. CSS({)

    Top: sym.posY, left:sym.posX

    });

    position2. CSS({)

    Top: sym.posY, left:sym.posX

    });

    };

    Stage.MouseMove

    sym.posX = e.pageX * sym.scaleratio + 30;

    sym.posY = e.pageY * sym.scaleratio;

    sym.infoLabel ();

  • Drag and drop helps!

    Hey guys,.

    I am in need of assistance with my drag and drop code. I have 3 Movieclips (mc, mc1, mc2). With an area (targetCircle). For the moment, it is when I do drag of the clips in the target area and then replace it with an another movieclip, the movieclip that was in the target area goes back to the original position of the movieclip that I just replaced with the recent movieclip.

    Thus for example shown in the picture below, 'mc' is in the target zone for the moment, and its original position is shown in the picture. Let's say I have take "mc2" and drag it to replace "mc" in the target area. What is happening is "mc" goes where "mc2" original position up to the top. Where "mc" should be going back to his appointed to the top post.

    Example Image:

    123.png1234.png

    Here is my code:

    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    showtext.visible = false;
    showtext1.visible = false;
    showtext2.visible = false;
    
    // initialize your draggable MovieClips
    mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
    mc1.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
    mc2.addEventListener(MouseEvent.MOUSE_DOWN, mouseHandler);
    
    var xpos:Number;
    var ypos:Number;
    var draggedMc:String;
    var hittingMc:String = "";
    
    function mouseHandler(e:MouseEvent):void{
        switch(e.type){
            case "mouseDown":
                draggedMc = e.target.name;
                xpos = e.target.x;
                ypos = e.target.y;
                setChildIndex(getChildByName(e.target.name), this.numChildren-1);
                e.target.startDrag();
                stage.addEventListener(MouseEvent.MOUSE_UP, mouseHandler);
            break;
            case "mouseUp":
                stopDrag();
                stage.removeEventListener(MouseEvent.MOUSE_UP, mouseHandler);
                checkPosition();
            break;
            default:
                trace("Error");
            break;
        }
    }
    function checkPosition():void{
        // tests if the draggable object hits the targetCircle
        if(getChildByName(draggedMc).hitTestObject(targetCircle)){
            var xEndPoint:Number = targetCircle.x + ((targetCircle.width / 15) - (getChildByName(draggedMc).width / 15));
            var yEndPoint:Number = targetCircle.y + ((targetCircle.height / 15) - (getChildByName(draggedMc).height / 15));
        
         if(getChildByName(draggedMc) == mc) {
              showtext.visible = true; 
              }else{
                   showtext.visible = false; 
              }
              
              if(getChildByName(draggedMc) == mc1) {
              showtext1.visible = true; 
              }else{
                   showtext1.visible = false; 
              }
              
              if(getChildByName(draggedMc) == mc2) {
              showtext2.visible = true; 
              }else{
                   showtext2.visible = false; 
              }
              
              if(hittingMc == ""){
                var tween1:Tween = new Tween(getChildByName(draggedMc),"x",Strong.easeOut,getChildByName(draggedMc).x,xEndPoint,.5,true);
                var tween2:Tween = new Tween(getChildByName(draggedMc),"y",Strong.easeOut,getChildByName(draggedMc).y,yEndPoint,.5,true);
                hittingMc = draggedMc;
            }
            else if(hittingMc != "" && hittingMc != draggedMc){
                var tween3:Tween = new Tween(getChildByName(draggedMc),"x",Strong.easeOut,getChildByName(draggedMc).x,xEndPoint,.5,true);
                var tween4:Tween = new Tween(getChildByName(draggedMc),"y",Strong.easeOut,getChildByName(draggedMc).y,yEndPoint,.5,true);
                var tween5:Tween = new Tween(getChildByName(hittingMc),"x",Strong.easeOut,getChildByName(hittingMc).x,xpos,.5,true);
                var tween6:Tween = new Tween(getChildByName(hittingMc),"y",Strong.easeOut,getChildByName(hittingMc).y,ypos,.5,true);
                hittingMc = draggedMc;
            }else{
                var tween7:Tween = new Tween(getChildByName(draggedMc),"x",Strong.easeOut,getChildByName(draggedMc).x,xEndPoint,.5,true);
                var tween8:Tween = new Tween(getChildByName(draggedMc),"y",Strong.easeOut,getChildByName(draggedMc).y,yEndPoint,.5,true);
            }
        }
         
         
         
        else if(hittingMc == draggedMc) {
            hittingMc = "";
        }
         
         else{
            var tween9:Tween = new Tween(getChildByName(draggedMc),"x",Strong.easeOut,getChildByName(draggedMc).x,xpos,.5,true);
            var tween10:Tween = new Tween(getChildByName(draggedMc),"y",Strong.easeOut,getChildByName(draggedMc).y,ypos,.5,true);
        }
    }
    
    

    Import fl.transitions.Tween;
    Fl.transitions.easing import. *;

    ShowText.Visible = false;
    showtext1. Visible = false;
    showtext2. Visible = false;

    var xArr:Array = new Array();
    var yArr:Array = new Array();


    initialize your draggable MovieClips
    for (var i: int = 0; i<>
    This ["mc" + i] .addEventListener (MouseEvent.MOUSE_DOWN, mouseHandler);
    xArr.push (this ["mc" + i] .x);
    yArr.push (this ["mc" + i] there);
    }

    var xpos:Number;
    var ypos:Number;
    var draggedMc:String;
    var hittingMc:String = "";

    function mouseHandler(e:MouseEvent):void {}
    {Switch (e.type)}
    case "mouseDown":
    draggedMc = e.target.name;
    PosX = e.target.x;
    YPos = e.target.y;
    setChildIndex (getChildByName (e.target.name), this.numChildren - 1);
    e.target.startDrag ();
    stage.addEventListener (MouseEvent.MOUSE_UP, mouseHandler);
    break;
    case "mouseUp":
    stopDrag();
    stage.removeEventListener (MouseEvent.MOUSE_UP, mouseHandler);
    checkPosition();
    break;
    by default:
    trace ("Error");
    break;
    }
    }
    function checkPosition (): void {}
    tests whether the draggable object strikes the targetCircle
    {if (getChildByName (draggedMc) .hitTestObject (targetCircle))}
    var xEndPoint:Number = targetCircle.x + ((targetCircle.width / 15)-(getChildByName (draggedMc) .width / 15));
    var yEndPoint:Number = targetCircle.y + ((targetCircle.height / 15)-(getChildByName (draggedMc) .height / 15));
       
    If (getChildByName (draggedMc) == mc0) {}
    ShowText.Visible = true;
    } else {}
    ShowText.Visible = false;
    }
             
    If (getChildByName (draggedMc) == mc1) {}
    showtext1. Visible = true;
    } else {}
    showtext1. Visible = false;
    }
             
    If (getChildByName (draggedMc) == mc2) {}
    showtext2. Visible = true;
    } else {}
    showtext2. Visible = false;
    }
             
    If (hittingMc == "") {}
    var tween1:Tween = new Tween (getChildByName (draggedMc), "x", Strong.easeOut, getChildByName (draggedMc) .x, xEndPoint,.5, true);
    var tween2:Tween = new Tween (getChildByName (draggedMc), "y", Strong.easeOut, getChildByName (draggedMc) there, yEndPoint,.5, true);
    hittingMc = draggedMc;
    }
    ElseIf (hittingMc! = "" & hittingMc!) = draggedMc) {}
    var tween3:Tween = new Tween (getChildByName (draggedMc), "x", Strong.easeOut, getChildByName (draggedMc) .x, xEndPoint,.5, true);
    var tween4:Tween = new Tween (getChildByName (draggedMc), "y", Strong.easeOut, getChildByName (draggedMc) there, yEndPoint,.5, true);
    var temp:int=int(hittingMc.charAt(2));
    var tween5:Tween = new Tween (getChildByName (hittingMc), "x", Strong.easeOut, getChildByName (hittingMc) .x,xArr [temp],. 5, true);
    var tween6:Tween = new Tween (getChildByName (hittingMc), "y", Strong.easeOut, getChildByName (hittingMc) there,yArr [temp],. 5, true);
    hittingMc = draggedMc;
    } else {}
    var tween7:Tween = new Tween (getChildByName (draggedMc), "x", Strong.easeOut, getChildByName (draggedMc) .x, xEndPoint,.5, true);
    var tween8:Tween = new Tween (getChildByName (draggedMc), "y", Strong.easeOut, getChildByName (draggedMc) there, yEndPoint,.5, true);
    }
    }
        
        
        
    of other if(hittingMc == draggedMc) {}
    hittingMc = "";
    }
        
    else {}
    var tween9:Tween = new Tween (getChildByName (draggedMc), "x", Strong.easeOut, getChildByName (draggedMc) .x, xpos,.5, EU tr);
    var tween10:Tween = new Tween (getChildByName (draggedMc), "y", Strong.easeOut, getChildByName (draggedMc) there, ypos,.5, EU tr);
    }
    }

    Note: Once you drag the first position the xpos and ypos are updated to the item newly slipped. That's why itz to another location. Please copy and paste the code it works.

  • For Drag and Drop, event shooting experts

    I'm working on an application that integrates several drag and drop lists (TileLists in this case). Each of them is related to its own instance of arraylist, but items are allowed to freely drag between the lists. The problem I encountered is that arraylist containing the data to the tilelist is not updated before the dragDrop and dragComplete events (seems to happen immediately after my respective event handlers are executed). Is there an event that I subscribe to that fires after ALL done drag and drop updates were committed to the underlying data source?

    For anyone else running into this problem, the solution that seems to work is based on the list updateComplete event. You can ignore the dragComplete and dragDrop events.

Maybe you are looking for