Drag and drop to target

Hey.  A couple of weeks ago Kglad from the forums created some code for me for a drag and drop function.  It works great.  Unfortunatly im having to extend  to more draggable objects.  So they will be within another movie clip so i can have them scrolling.  After making the scroll, the draggable objects dont register on the droptarget as they are within another movie clip.  Below is i think the part of the code that needs to be changed so the draggable objects know where to find the drop target.
Hope that makes sense.
Could anybody help?
Thanks
this.stopDrag();
if(eval(this._droptarget)==droptargetMC){

droptargetMC
probably needs to be changed.  you could take a long-shot and try:
_parent.droptargetMC
but you'll probably need to see the code that defined droptargetMC and explain where it's defined relative to the location of the stopDrag() code.

Similar Messages

  • Drag and drop to target simple errors, expecting identifier?

    im creating a drag and drop. moving a guitarest name to a target e.g draging a movieclip called slash to a dynamic text box called box_slash this is my code and i get 2 stupid errors but have been up all night and cant figure it out!
    flash cs5 actionscript 3, is this code for actionscript3 i found the base for it here: http://edutechwiki.unige.ch/en/Flash_drag_and_drop_tutorial any help would be incredible as it for an assignment and im new to flash
    var hits = 0;
    // Register mouse event functions
    slash.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    slash.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    clapton.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    clapton.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    hendrix.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    hendix.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    // Define a mouse down handler (user is dragging)
    function mouseDownHandler(evt:MouseEvent):void {
              var object = evt.target;
              // we should limit dragging to the area inside the canvas
              object.startDrag();
    function mouseUpHandler(evt:MouseEvent):void {
              var obj = evt.target;
              // obj.dropTarget will give us the reference to the shape of
              // the object over which we dropped the circle.
              var target = obj.dropTarget;
              // If the target object exists the we ask the test_match function
              // to compare moved obj and target where it was dropped.
              if (target != null)
                        test_match(target, obj);
              obj.stopDrag();
    function test_match(target,obj) {
              // test if either one of the four pairs match
              if ( (target == box_slash && obj == slash) ||
                 (target == box_clapton && obj == clapton) ||
                   (target == box_hendrix && obj == hendrix) || )
                        // we got a hit
                        hits = hits+1;
                        textField.text = "Correct! :)";
                        // make the object transparent
                        obj.alpha = 0.5;
                        // kill its event listeners - object can't be moved anymore
                        obj.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
                        obj.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
                        // Test if we are done
                        if (hits == 3)
                                  textField.text = "Well Done";
              else
                        textField.text = "wrong! :(";
    the errors are: i have highlighted the lines
    Scene 1, Layer 'Actions', Frame 1, Line 39
    1084: Syntax error: expecting rightparen before leftbrace.
    Scene 1, Layer 'Actions', Frame 1, Line 38
    1084: Syntax error: expecting identifier before rightparen.

    Thankyou very much that does get rid of that error now i get
    Scene 1, Layer 'Actions', Frame 1, Line 42
    1120: Access of undefined property textField.
    Scene 1, Layer 'Actions', Frame 1, Line 51
    1120: Access of undefined property textField.
    Scene 1, Layer 'Actions', Frame 1, Line 56
    1120: Access of undefined property textField.
    now im sure this is simple but im as im sure you have figured out im a complete noob to flash
    textField.text = "Correct! :)";
      textField.text = "Well Done";
    textField.text = "wrong! :(";
    is this something to do with an instance name?

  • Drag and Drop | Text | Submit | PLEASE HELP

    Hi. I really need help.  THANK YOU in advance.
    I am building a voting contact from in flash profession with AS3. The functionality will allow users to drag and drop choices OR add their own allow them to submit their TOP 5 choices.
    PROBLEM:
    1. Drag and drop text is not submitted when it is dragged into the editable text field.
    HOW CAN I DO THIS TO ALLOW FOR DRAG AND DROPPED ITEMS TO BE SUBMITTED or TEXT THAT IS MANUALLY ENTERED.
    This can be seen HERE: http://pttdt.com/winnipegcafes.php
    AS3 Code used thus far:
    /* Drag and Drop
    Makes the specified symbol instance moveable with drag and drop.
    choice_1.buttonMode = true;
    choice_1.mouseChildren = false;
    choice_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
    function fl_ClickToDrag(event:MouseEvent):void
                choice_1.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
    function fl_ReleaseToDrop(event:MouseEvent):void
                choice_1.stopDrag();
    /* Drag and Drop
    Makes the specified symbol instance moveable with drag and drop.
    choice_2.buttonMode = true;
    choice_2.mouseChildren = false;
    choice_2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);
    function fl_ClickToDrag_2(event:MouseEvent):void
                choice_2.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);
    function fl_ReleaseToDrop_2(event:MouseEvent):void
                choice_2.stopDrag();
    /* Drag and Drop
    Makes the specified symbol instance moveable with drag and drop.
    choice_3.buttonMode = true;
    choice_3.mouseChildren = false;
    choice_3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);
    function fl_ClickToDrag_3(event:MouseEvent):void
                choice_3.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);
    function fl_ReleaseToDrop_3(event:MouseEvent):void
                choice_3.stopDrag();
    /* Drag and Drop
    Makes the specified symbol instance moveable with drag and drop.
    choice_4.buttonMode = true;
    choice_4.mouseChildren = false;
    choice_4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_4);
    function fl_ClickToDrag_4(event:MouseEvent):void
                choice_4.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_4);
    function fl_ReleaseToDrop_4(event:MouseEvent):void
                choice_4.stopDrag();
    /* Drag and Drop
    Makes the specified symbol instance moveable with drag and drop.
    choice_5.buttonMode = true;
    choice_5.mouseChildren = false;
    choice_5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);
    function fl_ClickToDrag_5(event:MouseEvent):void
                choice_5.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);
    function fl_ReleaseToDrop_5(event:MouseEvent):void
                choice_5.stopDrag();
    /* Mouse Click Event
    Clicking on the specified symbol instance executes a function in which you can add your own custom code.
    Instructions:
    1. Add your custom code on a new line after the line that says "// Start your custom code" below.
    The code will execute when the symbol instance is clicked.
    send_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
    function fl_MouseClickHandler(event:MouseEvent):void
                // Start your custom code
                // This example code displays the words "Mouse clicked" in the Output panel.
                trace(box_1.text);
                trace(box_2.text);
                trace(box_3.text);
                trace(box_4.text);
                trace(box_5.text);
                trace(theName.text);
                trace(theEmail.text);
                // End your custom code
    PLEASE HELP

    It can be fairly involved once you realize how many aspects need to be dealt with.  You'll need to find a tutorial that teaches you how to use drag and drop involving targets so that when you drop something you check if it hit a valid target (textfield in your case) and then process your text into that target.  You should try searching Google using terms like "AS3 drag drop tutorial" and "AS3 dropTarget tutorial"   Here's a link from the latter of the two that has links to tutorials that might help.
    http://forums.adobe.com/post!reply.jspa?message=3462293

  • [Ask] Drag and Drop Problem

    Hello all, i'm a new member here, and i just installed Adobe Flash Professional CS6 on my computer. I want to make a simple quiz with drag and drop feature in it. I want to drag Square A (Square_1) from the first position marked with "STAR" into the white square (Target_1), i've already made the script, but everytime i drop the square A on the white square (Target_1), it won't fit exactly on the white square (Target_1). I use this script to make drag and drop with target working :
    var startX:Number;
    var startY:Number;
    Square_1.addEventListener(MouseEvent.MOUSE_DOWN, pickMe);
    Square_1.addEventListener(MouseEvent.MOUSE_UP, dropMe);
    function pickMe(event:MouseEvent):void {
        event.target.startDrag(true);
        startX = event.target.x;
        startY = event.target.y;
    function dropMe(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 == Target_1){
            event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickMe);
            event.target.removeEventListener(MouseEvent.MOUSE_UP, dropMe);
            event.target.buttonMode = false;
            event.target.x = Target_1.x;
            event.target.y = Target_1.y;
        } else {
            event.target.x = startX;
            event.target.y = startY;
    Any help would be appreciated. Thank you.

    if A and that white square both had reg points in their centers or both at the upper left, you would not have a problem.  as it is with the white square with upper left reg point and A with center reg point, you can use:
    event.target.x = Target_1.x+Target_1.width/2;
            event.target.y = Target_1.y+Target_1.height/2;
    but it would be better to use consistant reg points throughout your app.

  • Drag and Drop game with only two targets

    I created a drag and drop activity where their are five boxes that are supposed to go in to two columns in any order. I found a tutorial online that I based this activity off of.
    The problem is that the tutorial shows you how to make a target for each mc which has worked for all the activities I've made except for this one where I need only two targets. How would I change it so I can have multiple mc's drop on to one target?
    This is my AS:
    var score:Number = 0;
    var objectoriginalX:Number;
    var objectoriginalY:Number;
    growing_mc.buttonMode = true;
    growing_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
    growing_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    gorging_mc.buttonMode = true;
    gorging_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
    gorging_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    dormancy_mc.buttonMode = true;
    dormancy_mc.addEventListener(MouseEvent.MOUSE_DOWN  , pickupObject);
    dormancy_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    cystform_mc.buttonMode = true;
    cystform_mc.addEventListener(MouseEvent.MOUSE_DOWN  , pickupObject);
    cystform_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
    hosttrans_mc.buttonMode = true;
    hosttrans_mc.addEventListener(MouseEvent.MOUSE_DOW  N, pickupObject);
    hosttrans_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 matchingTargetisplayObject = getChildByName(matchingTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget){
    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;
    score++;
    scoreField.text = String(score);
    } else {
    event.target.x = objectoriginalX;
    event.target.y = objectoriginalY;
    if(score == 5){
    response_mc.gotoAndStop(2);

    var matchingTargetName:String =(event.target.name).substring(0, 1);
    Change the name of the target to A and B and the mc A1, A2, A3, A4... and B1, B2,B3...

  • Moving answers in a quiz once they have been matched to a target in using drag and drop

    Hi,
    I am having a problem with some of my drag and drop quizzes that I'm wondering if anyone you might be able to help me with?
    In some drag and drop quizzes I have created, using the Infosemantics drag and drop light widget in Captivate 5.5, I can move the answer after having matched it to a target but before submittting.  Whereas in some quizzes I have created, the answers get stuck and do not let me move the answers after I have matched them to a target, even though I haven't submitted.  This leaves me no choice but to clear all my answers and start again if I have made a mistake. 
    Please can you tell me how to enable the answers to move even after they have been placed on a target? 

    Emma,
    Take a look at the troubleshooting tips on this page from the Infosemantics website:
    http://www.infosemantics.com.au/adobe-captivate-widgets/drag-and-drop/troubleshooting-widg et-issues
    Pay particular attention to the section entitled: "My drag and drop question works correctly sometimes, but not other times. "
    From the appearance of your slide, it looks like you may have removed some of the components from the quiz slide that are necessary for it to function correctly.  Try the test that this section of the troubleshooting suggests so that you can see if this is the case.  If it turns out that you have deleted some items, you'll need to recreate your quiz slide to get them back again.
    Hope this helps.

  • Drag and Drop with multiple targets

    I'm having a problem find a solution to my drag and drop problem.  Here is what this flash piece is basically supposed to do:
    9 dragable items on the stage
    5 targets, numbers 1 - 5, where the items can be placed
    5 of the 9 dragable items are the correct answer and the user needs to drag them to the correct target, and have to be in order from 1-5. (eg. let's say the instructions are:
    Please place the, in the correct order, the 5 steps to getting ready in the morning
    Drag items                                               Targets
    Brush teeth                                       1.                     
    Change oil in car                                2.                    
    Wash face                                         3.                   
    Put pants on                                      4.                    
    Shower                                              5.                     
    Get out of bed  
    Do tax's
    So far I have it so if you drop the correct answer into its correct target it snaps to it and disable it's eventListeners.  If you drop the drag item on the other targets they snap to it and disable it as well.  They only problem is if the user accidentally drops the item anywheres else on the stage it locks it in place.  Instead I want it to return to the orginal x and y position.  Can anyone help?!?
    Here is my code
    DragDrop.as
    package
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    public class DragDrop extends MovieClip
      public var _targetPiece:*;
      public function DragDrop()
       this.addEventListener(MouseEvent.MOUSE_DOWN, dragMovie);
       this.addEventListener(MouseEvent.MOUSE_UP, dropMovie);
       this.buttonMode = true;
      private function dragMovie(event:MouseEvent):void
       this.startDrag();
       this.filters = [new DropShadowFilter(0.5)];
       this.parent.addChild(this);
      private function dropMovie(event:MouseEvent):void
       this.stopDrag();
       this.filters = [];
      public function disable():void
       this.buttonMode = false;
       this.removeEventListener(MouseEvent.MOUSE_DOWN, dragMovie);
       this.removeEventListener(MouseEvent.MOUSE_UP, dropMovie);
    DragGame.as
    package
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import DragDrop;
    import BL;
    import BR;
    import BM;
    import TL;
    import TR;
    import TM;
    import BC;
    import TC;
    import BA;
    public class DragGame extends MovieClip
      private var bl:BL;
      private var br:BR;
      private var bm:BM;
      private var tl:TL;
      private var tr:TR;
      private var tm:TM;
      private var bc:BC;
      private var tc:TC;
      private var ba:BA;
      private var _totalPieces:Number;
      private var _currentPieces:Number;
      private var _submit:Number;
      private var _reveal:Number;
      public function DragGame()
       _totalPieces = 5;
       _currentPieces = 0;
       createPieces();
       _submit = 6;
       _reveal = 1;
      private function createPieces():void
       bl = new BL();
       addChild(bl);
       bl._targetPiece = blt_mc;
       bl.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition1(bl);
       br = new BR();
       addChild(br);
       br._targetPiece = brt_mc;
       br.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition2(br);
       bm = new BM();
       addChild(bm);
       bm._targetPiece = bmt_mc;
       bm.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition3(bm);
       tl = new TL();
       addChild(tl);
       tl._targetPiece = tlt_mc;
       tl.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition4(tl);
       tr = new TR();
       addChild(tr);
       tr._targetPiece = trt_mc;
       tr.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition5(tr);
       tm = new TM();
       addChild(tm);
       tm._targetPiece = tmt_mc;
       tm.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition6(tm);
       bc = new BC();
       addChild(bc);
       bc._targetPiece = trt_mc;
       bc.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition7(bc);
       tc = new TC();
       addChild(tc);
       tc._targetPiece = trt_mc;
       tc.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition8(tc);
       ba = new BA();
       addChild(ba);
       ba._targetPiece = trt_mc;
       ba.addEventListener(MouseEvent.MOUSE_UP, checkTarget);
       piecePosition9(ba);
      private function checkTarget(event:MouseEvent):void
       if(event.currentTarget.hitTestObject(event.currentTarget._targetPiece))
        event.currentTarget.x = event.currentTarget._targetPiece.x;
        event.currentTarget.y = event.currentTarget._targetPiece.y;
        event.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, checkTarget);
        event.currentTarget.disable();
        _currentPieces ++;
        _submit --;
        if(_currentPieces >= _totalPieces)
         wrong_txt.visible = false;
         answer_txt.visible = true;
        if(_submit <= _reveal)
         submit_mc.visible = true;
         submit_mc.buttonMode = true;
       else
        event.currentTarget.x= event.currentTarget.dropTarget.parent.x;
        event.currentTarget.y= event.currentTarget.dropTarget.parent.y;
        event.currentTarget.disable();
        if(_submit <= _reveal)
         submit_mc.visible = true;
         submit_mc.buttonMode = true;
      private function piecePosition1(piece:*):void
       piece.x = 50.2;
       piece.y = 87.2;
       piece._origX = 50.2;
       piece._origY = 87.1;
      private function piecePosition2(piece:*):void
       piece.x = 50.2;
       piece.y = 109.2;
       piece._origX = 50.2;
       piece._origY = 109.2;
      private function piecePosition3(piece:*):void
       piece.x = 50.2;
       piece.y = 131.2;
       piece._origX = 50.2;
       piece._origY = 131.2;
      private function piecePosition4(piece:*):void
       piece.x = 50.2;
       piece.y = 153.3;
       piece._origX = 50.2;
       piece._origY = 153.3;
      private function piecePosition5(piece:*):void
       piece.x = 50.2;
       piece.y = 175.3;
       piece._origX = 50.2;
       piece._origY = 175.3;
      private function piecePosition6(piece:*):void
       piece.x = 50.2;
       piece.y = 197.3;
       piece._origX = 50.2;
       piece._origY = 197.3;
      private function piecePosition7(piece:*):void
       piece.x = 50.2;
       piece.y = 219.4;
       piece._origX = 50.2;
       piece._origY = 219.4;
      private function piecePosition8(piece:*):void
       piece.x = 50.2;
       piece.y = 241.4;
       piece._origX = 50.2;
       piece._origY = 241.4;
      private function piecePosition9(piece:*):void
       piece.x = 50.2;
       piece.y = 263.7;
       piece._origX = 50.2;
       piece._origY = 263.7;

    create an array of your droptargets (eg, droptargetA) and check if the object is dropped on a droptarget.  you don't even need the if-branch of the following if-else unless you do something that depends on whether the correct droptarget is hit.
    function checkTarget(event:MouseEvent):void
       if(event.currentTarget.hitTestObject(event.currentTarget._targetPiece ))
        event.currentTarget.x = event.currentTarget._targetPiece.x;
        event.currentTarget.y = event.currentTarget._targetPiece.y;
        event.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, checkTarget);
        event.currentTarget.disable();
       else
    var x:Number=event.currentTarget.dropTarget._origX;
    var y:Number=event.currentTarget.dropTarget._origY;
    for(var i:uint=0;i<droptargetNum;i++){
        if(event.currentTarget.hitTestObject(droptargetA[i] )){
    x=droptargetA[i].x;
    y=droptargetA[i].y;
    break
    event.currentTarget.x=x;
    event.currentTarget.y=y;

  • Cannot change target sound in drag and drop to "no sound" once a default sound is selected in Captivate 8

    I was trying out all the options for a drag and drop interaction in Captivate 8 and selected one of the default sounds for a target. I want to change it back to "no sound", but the selection never sticks. Is there something I'm missing or is this a "feature"?

    When you go to the “Format” tab of the drag and drop properties, there is an option called “audio” (right below the “depth” option).
    It has default sounds you can pick (sound1, sound2, sound3, and incorrect sound). Or you can browse to an audio file. If I select one of the default sounds, and then decide not to use any sound, it will not change to the “none” option. I have to delete the drag and drop interaction and start over.
    Robert Willis  | 616.935.1155 | [email protected]
    Measurement always affects performance.
    The right measurement always improves results .
    Find out how. Download our Return On People eBook.<http://bit.ly/151jD9C>
    This message is for the addressee only and may contain confidential and/or privileged information. You may not use, copy, disclose, or take any action based on this message if you are not the addressee. If you have received this message in error, please contact the sender and delete the message from your system.

  • Drag and drop Images into Multiple Targets

    Hello,
    I want to alter the NI example "Drag and Drop - Multiple Data Types to Start Drag" to use multiple image Targets.  The current VI only allows for dropping image into a single Target.  I want to duplicate the target window a few times, in order to drop different images into each different Target.  I can't seem to figure out how the VI recognizes and differentiates the Targets. 
    Thanks,
    Labview 2009 SP1

    Hello,
    Please see attached... That's a simple way to perform what you need : each target is handled in the same event case (the target is differentiated by using control refnum).
    Hope this helps,
    J.
    Attachments:
    Screenshot.jpg ‏132 KB

  • Drag and drop to multiple targets

    Hi
    Im trying to create a simple drag and drop app where you can drap a movieclip into multiple areas.
    This is the code i have so far (taken from a tutorial i found) thats works perfectly for 1 target but not for multiples. I initially tried giving the targets the same instance name but that didnt work.
    stop();
    var startX:Number;
    var startY:Number;
    square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function pickUp(event:MouseEvent):void {
    square_mc.gotoAndStop (2);
    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();
    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 = "you have 5 days left";
      event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
      event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
      event.target.buttonMode = false;
      event.target.x = myTarget.x;
      event.target.y = myTarget.y;
       } else {
      square_mc.gotoAndStop (1);
      event.target.x = startX;
      event.target.y = startY;
    if(counter == 4){
            reply_txt.text = "Congrats, you're finished!";
    square_mc.buttonMode = true;
    does anyone have any ideas?
    Many thanks
    Simon

    Here you go, I changed a couple things. First, I made the "decision" that all your drop targets would be named 'target'.
    stop();
    var startX:Number;
    var startY:Number;
    square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    square_mc.buttonMode = true;
    function pickUp(event:MouseEvent):void
         square_mc.gotoAndStop (2);
         event.target.startDrag()//true);
         event.target.parent.addChild(event.target);
         startX = event.target.x;
         startY = event.target.y;
    function dropIt(event:MouseEvent):void
            // changed the bit here to set 'myTarget' after the null and name checks are made
         event.target.stopDrag();
         if (event.target.dropTarget != null && event.target.dropTarget.parent.name == "target")
              var myTarget = event.target.dropTarget.parent;
              reply_txt.text = "you have 5 days left";
              event.target.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
              event.target.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
              event.target.buttonMode = false;
              event.target.x = myTarget.x;
              event.target.y = myTarget.y;
              } else {
              square_mc.gotoAndStop (1);
              event.target.x = startX;
              event.target.y = startY;
         if(counter == 4)
            reply_txt.text = "Congrats, you're finished!";
    HTH!
    -Ted

  • Drag and Drop 2 objects 1 target

    I am fairly new to Flash and trying to create a drag and drop.  I have been following the tutorial here (http://monkeyflash.com/tutorials/flash-drag-and-drop/). One change I made to this tutorial was to have the object disappear when it is dropped on the target.  Following these directions I was able to successfully build a drag and drop with one object to one target.  My question is what if I want to have multiple objects go to the same target?  For example in the tutorial what if I added a second square object and wanted both to go to the one square target.
    Any help would be greatly appreciated!

    As long as the target is still accessible as a target you can drag as many objects to as you want (one at a time).  To help do that, when you drop an object on the target and make it disappear, you either need to make that dropped object go away ( removeChild(dropped) ) so that it is not blocking the way or move the target above the dropped object ( addChild(target) ).

  • Drag and Drop Interaction with 50+ Drop Targets

    Hello,
    I'm fairly new to Captivate 7 but very familiar with Flash. I'm tasked with a project that I would like to do with the drag and drop interaction widget from Captivate 7. Basically, we need our learners to identify the locations of our resorts on a map. Select the name of the resort, drag and drop it in the city/state or country where located. My question is can Captivate handle this task? To me, it seems as a large task for Captivate to handle, and so I was thinking of coding it in Flash.
    Here is what I need:
    1.- List of all the properties at bottom with the drop target being a map of the US or world and have the location for each property as the drop target.
    2.- When the resort/property is selected, the name will change to the three letter code. Example: New York City, when clicked = NYC and the map itself to reflect the 3 letter code once dropped on the map if correct.
    3. If incorrect, the listed item will revert to the long name and return to the list.
    4. If this can be graded, it would be best.
    I can break the project into different regions but if I wanted to keep all 300+ properties in one module, will it be an issue? At the very least, I would need to do a minimum of about 50 per module.
    Thanks all! I've found this forum to be extremely helpful and the members seem to be eager to help.

    var matchingTargetName:String =(event.target.name).substring(0, 1);
    Change the name of the target to A and B and the mc A1, A2, A3, A4... and B1, B2,B3...

  • My drag images disappear when they are dropped on a correct drop target during the drag and drop interaction.

    What am I missing. The opacity is at 100%. The drop target is a highlighted box from objects. I am using Captivate 8.

    Hi there,
    You might want to make sure your Depth setting is not set to Back instead of Front on your drop target(s).
    The Depth setting is accessed via the Drag and Drop window/panel under Format setting while you have your drop target selected.
    If your Depth setting is set to Back, especially if your opacity is set to 100% on your highlight box/drop target, your drag image would go behind your drop target giving the effect of disappearing behind your highlight box - especially if the drop target is larger than the drag image.

  • 1 Success Caption for Multiple Targets in a Drag and Drop Interaction

    I see how I can add success captions to each target in a drag and drop interaction, but can you apply only 1 success caption multiple targets?

    The boundaries of smartshapes were overlapping with each other. For example, the smartshape on 1st line was overlapping with the one on 2nd line. Due to this, every time you place the text caption "Investment" on the smartshape on 2nd line, it automatically moved to the smartshape on 1st line. As a result, you could never get the answer right, and hence you never saw the Success Caption.
    Solution: Move the smartshapes away from each other (or resize them), and ensure that there are no overlaps.
    2,  The number of attempts for this interaction was set to Infinite. So, you have to play this until you get it right, but you could not get it right because of the reasons mention above. That is why you never saw the Failure Caption.
    Solution: Clear the Infinite check box in the Action accordion and specify the required number of attempts. You will get the Failure Caption if you don't get it right in those attempts.
    I just tested these solutions and they worked fine. Let me know if you still face any issues.

  • Flash drag and drop not finding targets in Captivate

    I created a drag and drop game in Flash CS4 using Actionscript 2 which allows you to pull clothing onto a stick figure. If you get the clothes in the right place, over the target, then they stick, if not they return to their original position. It works fine but when I open it in Captivate 4 the targets no longer hold the objects. No matter where you place the clothes icons they will return to their original position.
    I have captivate set up for the correct Actionscript and the fps in captivate and the swf are the same. I've included the code I wrote below. Please help if you have any answers as to why this is happening.
    shirt_mc.onPress=function(){
    startDrag(this);
    shirt_mc.onRelease=shirt_mc.onReleaseOutside=function(){
    stopDrag();
    if (this._droptarget == "/targetShirt") {
    this.onTarget=true;
    _root.targetShirt.gotoAndStop(2);
    }else{
    this.onTarget=false;
    _root.targetShirt.gotoAndStop(1)
    shirt_mc.myHomeX=shirt_mc._x;
    shirt_mc.myHomeY=shirt_mc._y;
    shirt_mc.onMouseDown=function(){
    //this variable tells us if the mouse is up or down
    mousePressed=true;
    shirt_mc.onMouseUp=function(){
    mousePressed=false;
    shirt_mc.onEnterFrame=function(){
    //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
    // then move the MC back to its original starting point (with a smooth motion)
    if(mousePressed==false&&this.onTarget==false){
    this._x-=(this._x-this.myHomeX)/5;
    this._y-=(this._y-this.myHomeY)/5;
    pants_mc.onPress=function(){
    startDrag(this);
    pants_mc.onRelease=pants_mc.onReleaseOutside=function(){
    stopDrag();
    if (this._droptarget == "/targetPants") {
    this.onTarget=true;
    _root.targetPants.gotoAndStop(2);
    }else{
    this.onTarget=false;
    _root.targetPants.gotoAndStop(1)
    pants_mc.myHomeX=pants_mc._x;
    pants_mc.myHomeY=pants_mc._y;
    pants_mc.onMouseDown=function(){
    //this variable tells us if the mouse is up or down
    mousePressed=true;
    pants_mc.onMouseUp=function(){
    mousePressed=false;
    pants_mc.onEnterFrame=function(){
    //all these actions basically just say "if the mouse is up (in other words - the clip is not being dragged)
    // then move the MC back to its original starting point (with a smooth motion)
    if(mousePressed==false&&this.onTarget==false){
    this._x-=(this._x-this.myHomeX)/5;
    this._y-=(this._y-this.myHomeY)/5;

    Hi all,
    Thanks for the informative replies.  My main issue seems to be when adding animations.  For example (I have included one below
    ).  I add this animation to my project and it runs perfectly.  I then add another, very similar animation, and the sound dissapears completely in the previous one! I remove the one added, preview the project again and the first animation works again!
    The only access I make to Root is through the successful click on the otherTARGET, that tells captivate to move to the next slide.  Could this be the root (exuse the pun) of my problems?
    Any help appreciated!
    stop();
    var target:Array=new Array(likelyTARGET,otherTARGET,other1TARGET);
    addListners();
    var more:Sound = new consequencefocuspeople();
    var less:Sound = new consequencemoreserious();
    function addListners(){
    for (var i in target) {   
    target[i].addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void
    var item:String = event.target.name;
    switch(item)
      case "otherTARGET":
         var mainmov:MovieClip = MovieClip(root);
          mainmov.rdcmndNextSlide = 1;
      break;
      case "other1TARGET":
      removeAllEventListner()
      var soundChannel:SoundChannel = more.play();
      soundChannel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
      break;
      case "likelyTARGET":
      removeAllEventListner()  
      var soundChannel2:SoundChannel = less.play();
      soundChannel2.addEventListener(Event.SOUND_COMPLETE, soundComplete);
      break;
    function soundComplete(event:Event):void {
    addListners()
    function removeAllEventListner()
    for (var i in target)
      target[i].removeEventListener(MouseEvent.CLICK, onClick); 
    thanks,
    tristan

Maybe you are looking for

  • How can I see a list of the url's in each of my bookmark folders?

    I recently began using Safari 5.0.6 (on OS 10.5.8), and there's a major change I find Very troubling and time-consuming!  Before, when I selected "Show all Bookmarks," when I clicked on a folder of bookmarks in the Collections panel on the left side

  • Intel iMac and PHotoshop Elements 4 compatability

    Can anyone tell me if Photshop Elements 4 will run on the new i-Mac with Intel Processor? I'd like to know before I buy it. The sales people say Yes, but does anyone have experience with it yet?

  • French DMEE format (customer payment)

    Hi, Has anyone done a parametrization around French DMEE format (ETEBAC) for incoming payment (customer) ? I'm looking for a process in order to integrate an incoming file from the bank into SAP with G/L posting and clearing customer's invoice. Would

  • Is it possible to round trip with Motion 5?

    I just want a send to motion feature. Are there 3rd party plugins that can do that for me? I would totally pay for it.

  • How to stop the bookmarks menu vanishing once a bookmark is selected

    Hi, my Firefox bookmarks are nested; when I select one, the bookmark menu vanishes, which means to open several similar-topic bookmarks in different tabs I need to continually re-open bookmarks and delve down to the same level. Is there any way of ma