Drag and Drop slide back Animation

Hello, I am working on a project for work and I ran into a bump on the road. I'm a noobie when it comes to programming and followed a tutorial for a game/question test drag / move for students. What I have so far, is that I'm able to drag and drop items I wanted in one spot without any problem. The question I am running across is when it moves the object to the wrong place, I want to make a nice blade to its original location, rather than just a jump quick return and there is. That's what I have so far for the code.

import flash.display.MovieClip;
import flash.events.MouseEvent;


var dragArray:Array = [square, circle];
var matchArray:Array = [squareMatch, circleMatch];
var currentClip:MovieClip;

var startX:Number;
var startY: number;


for (var i: int = 0; i < dragArray.length; i ++) {}
dragArray [i] .buttonMode = true;
dragArray [i] .addEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);
matchArray [i] .alpha is. 2;

}

function item_onMouseDown(event:MouseEvent):void {}
currentClip = MovieClip (event.currentTarget);
startX = currentClip.x;
startY = currentClip.y;
addChild (currentClip);
currentClip.startDrag ();
stage.addEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);
}
function stage_onMouseUp(event:MouseEvent):void {}
stage.removeEventListener (MouseEvent.MOUSE_UP, stage_onMouseUp);
currentClip.stopDrag ();
var int index = dragArray.indexOf (currentClip);
var matchClip:MovieClip = MovieClip (matchArray [index]);
{if (currentClip.hitTestObject (matchClip))}
currentClip.x = matchClip.x;
currentClip.y = matchClip.y;

currentClip.removeEventListener (MouseEvent.MOUSE_DOWN, item_onMouseDown);
currentClip.buttonMode = false;
} else {}
currentClip.x = startX;
currentClip.y = startY;
}

}

A quick way to achieve this is to use the Tween class.  Here it is in the form of Basic.  If search you in the help documentation, you can read more about each parameter and change them according to your needs

Import fl.transitions.Tween;   Add this option to import the class

function stage_onMouseUp(event:MouseEvent):void {}

...

} else {}

var twX:Tween = new Tween (currentClip, "x", null, currentClip.x, startX, 1, true);

var twY:Tween = new Tween (currentClip, "y", null, currentClip.y, startY, 1, true);

}

}

Many people prefer to use engines of interpolation of third party like TweenLite/TweenMax instead of the class because of the realization of better performance.

Tags: Adobe Animate

Similar Questions

  • Custom review info on drag and drop slides

    Hi all

    I want to do a personal study on a drag-and-drop slide.

    However, it seems not that I can get cpInReviewMode to trigger the visibility on my subject to review.

    Added the action advanced on enter. With the help of C9, latest patch.

    Try advanced action:

    IF (cpInReviewMode == 1)

    See the dd1

    Break

    ON THE OTHER

    Continue

    Also tried

    IF (cpInReviewMode == true)

    See the dd1

    Break

    ON THE OTHER

    Continue

    / Dan

    This slide drag & drop is set up as a question slide? The variable cpInReviewMode system is generally set to 1 for the quiz, when the user clicks on the review of the score slide.

    I suspect, didn't check that the Pause command is causing issues. This means that the read head stop on enter, maybe no time to show the hidden comments. I guess dd1's "feedback" that has been configured to be invisible in the output? You can try taking the Pause command? You can increase the duration of the slide or add a button with a break at the end of the slide. Of course, if you do not want to have a double Quiz time pauzé, this pause should be at the same time as the normal Submit button of D & D (1.5secs is the default value), and the next button can be made visible during the review with your conditional action.

  • 6.1: drag and drop slide on enter reset

    How can I reset all the objects on a drag and drop slide on enter Captivate 6.1 using the integrated brake and drop the widget?

    Hey Savy,

    Drag and Drop Interaction works similar to another question slide if it is included in the Quiz. IE if you answer it correctly, or if your attempts are more then it wont allow to resume interaction drag / move with in the same scope of Quiz. But if you try several Quiz (Quiz preferences > Attemps), it allows to resume interaction in your next Quiz attempt.

    or if it is not included in the Quiz, it resets the interaction on each slide to enter.

    Please submit an enhancement request in "Drag and Drop of the success of the legend. Link http://www.adobe.com/go/wish

    Thank you

    VERALINE Sukumaran.

  • 8 - Drag and Drop - Bounce Back answers that are out of sequence of Captivate

    Sorry if it's addressed somewhere, but my search results find anything. I'm building a drag and drop in which objects should be waived in order in various targets. I can get an object of bounce if it fell in the wrong place, but I also want the object to bounce back if it broke down (in the wrong order). For example, if point 2 fell in the right place, but in the wrong order, it will be returned. But I can't find an option for that. Any ideas? Thank you!

    I don't think there's a way to get there. Only drag sources that cannot be accepted by a drop target can be bounced. But with the sequence, the drag source must be accepted even if it is not in the correct order.

  • Drag and Drop indicator of progress

    Hello everyone,

    I really hope to get help here:

    I did a fun quiz with a drag and drop slides (which works fine).

    The next slide after slide slide - déposer is a regular question slide. The problem is that the progress indicator (Question 1 of the XX)

    ignores the blade drag / move (I know that it is not a question slide to drag-n - déposer)

    Is it possible to add the progress to this slide indicator drag-and - déposer?

    I am the first and only one with this problem?

    Any help is appreciated.

    Greetings

    Panthalassa

    P.S. I use captivate 7 If this helps

    Hello

    No, you're not the first. I blog for a long time already on creating a custom progress indicator. The reason at that time was that he could not be located in this version, and I've created some custom question that slides get either the progress indicator. Now D & D is one of these. Take a look on:

    Custom indicator progress - Captivate blog

    If you're on CP7 or later, you can replace the tip by a joint action (easier to transfer to other projects) and I think that the statement of increment in the drop-down list advanced Actions was already available for 7. It can replace the Expression in the action described to increment the counter.

    Lilybiri

  • Tip action to show only a previous button on a slide so the learner clicked on the button Submit on Drag and Drop

    I am a user of long date Captivate and have dabbled with advanced Actions and Variables, so know just enough to get me in trouble. Hoping someone can help me with what I hope is a simple tip action:

    I am currently using CP8 and created a training where learners click on a map of building to go to different "rooms" to complete an interaction drag-and - déposer a certain topic related HR. The problem is that some of my learners test forget what 'rooms' they have already read and will click on those they have already visited. I added a back button, so that they can return to the map if they made a mistake, but now they are able to leave the slide without completing the interaction drag and drop.

    Basically, I need to hide the back button unless the learner has already completed (for example, the user clicks on the button submit to) the Drag and Drop interaction, but I'm not sure how to set up. Can anyone help?

    Thank you!

    Hide the button back to begin with. A tip action can be triggered by an event the success and failure of the & slipped. I guess that you will need at least two commands:

    • View the "back" button
    • Go to the next slide.

    It seems the simplest solution. You can also ignore the slide D & D when they enter a second time, but then you will need a Boolean variable to be turned on/off by these same events and a conditional action on which checks this variable and immediately jumps to the next slide when it is set to 1.

  • Drag and drop the blocks slide the whole project

    Hello

    my project structure looks like this more or less:

    (1) ' normal glide. "

    (2) a slide with drag and drop tasks

    (3) sliding normal. "

    (4) Quiz random Question pool slides

    (5) ' normal glide. "

    What is the problem? When the quiz is finished and you click on view or try again button, drag and drop (No. 2) then appear it works correctly as long as the blade drag-and - déposer is removed. What is the problem?

    BTW. Could you suggest me how to randomize the slides in question with regard to the manufacture of new parts inside to open a project? In other words, I need allow the user to get a new set of random questions after you click try again. I don't want him to get the same as it had previously.

    See you soon

    It is only possible to get a new set of questions at random, if the course is raised.

    Regarding your first question: is slide it drop & set up as a question? If it is included in the Quiz, this is the normal behavior of recovery and review both will get back to the D & D slide.

  • in any case to allow drag and drop on the BACK window?

    How to enable drag and drop on the BACK window?
    THX

    Hi fs - ab,

    You can use 3rd party tools that replace or enhance the Explorer.

    FileMenu Tools - free - adds many functions
    http://www.LopeSoft.com/en/fmtools/info.html

    I hope this helps.

  • Why is it not my Drag and Drop let me it slide?

    Hello

    I created an interaction drag-and - déposer in CP8. I have about 40 seconds of audio before I want the interaction drag and drop to become active, so my drag source and targets are hidden for 40 seconds. I have D & D put on pause after 42 seconds.

    When I saw my slide, it doesn't allows me to drag my source at all. In fact, the only time wherever it allows me to do it, is if I put the source and the target is displayed at the beginning of the slide.

    I have to create two slides? To play the audio and then automatically move to a second slide with the D & D just to this topic?

    Thank you

    Kristen

    It's one of the problems with drag & drop: objects must be programmed at the beginning of the slide.  If this is not possible, as I already had the requirement in many projects, you need to split into two blades.

  • How to go to the next slide during Drag and Drop

    I'm trying to go automatically to the next slide after the user makes a three 'drop zone' drag and drop.

    I see the action on the successes in the Panel. I chose to go to the next slide, but nothing happens after I have test.

    I also put in place the right answers for the drop areas three and thought that could trigger the part of "success."

    but still nothing happens.

    Any thoughts?

    Hi again,

    I understand, but in order to move to the next slide automatically the drag and drop must be introduced. It doesn't matter whether or not you include your drag and drop in a quiz. The option to send automatic drag / move it will include not a quiz, is to check if the answers are correct or not. You can leave to include it in an unchecked quiz.

    Thank you!

  • How to build a drag and drop multimeter lead using Flash animation?

    I'm building a virtual multimeter to test simulated circuits. I would like to be able to drag a lead animation test multimeter to a circuit point and drop it on a target. The static drag and drop is not my problem. I would like some suggestions on how I can animate the movement of the head itself. Any suggestion would be appreciated.

    you want something to "follow the mouse", but do not be dragged?

    If so, use a loop (enterframe) and facilitate the position of the object with the mouse:

    Object.x += speed * object.x +(1-speed) * mouseX;

  • Drag and drop the game lively bounce back

    Hello


    What I'm trying to do is to make a rebound for a drag and drop game, so if the object fell in a place that does not conform the hitTest, it bounces to a location of the pre set.


    It seems simple, but there's obviously something works do not. Just so that people know that I'm a total newbie when it comes to code in actionscript, so please be nice, because I probably won't understand what you're talking about.

    In any case, here's the code for the click of film that is moved.

    (press)
    {
    startDrag (this, false, 0, 0, 600, 400);
    }
    (release)
    {
    stopDrag();
    If (this.hitTest (_parent. MC_TargetAmpmeter))
    {
    This ._x = _parent. MC_TargetAmpmeter._x;
    This ._y = _parent. MC_TargetAmpmeter._y;
    _root. AmpmeterCorrect = true;
    }
    on the other
    {
    BounceBack.call (mx.transitions.easing.Bounce.easeOut);

    function BounceBack (easetype)
    {
    var start = getProperty (Ampmeter, _x);
    xEnd = 475.3 var;
    var mc = ammeter;
    BounceBack = new mx.transitions.Tween (mc, "_x", easeType, begin, xEnd,.2, true);
    }

    This ._x = 475.3;
    This ._y = 98.0;
    }
    }

    If you can help I'll be very grateful

    Thank you

    DrTux

    A couple of shouldn'ts... You should not nested named functions.  You should not place the code on objects... but we will pass on that for now.  Try using the following code on the object...

    (press)
    {
    this.startX = 475.3;  Use this ._x instead of 475.3
    this.startY = 98.0;   Use this ._y instead of 98.0
    startDrag (this, false, 0, 0, 600, 400);
    }

    (release)
    {
    stopDrag();
    If (this.hitTest (_parent. MC_TargetAmpmeter))
    {
    This ._x = _parent. MC_TargetAmpmeter._x;
    This ._y = _parent. MC_TargetAmpmeter._y;
    _root. AmpmeterCorrect = true;
    }
    on the other
    {
    _parent.bounceBack (this);
    }
    }

    And place the following code in a frame on the timeline that conatins the movieclip moved...

    Import mx.transitions.Tween;
    Import mx.transitions.easing.Bounce;
       
    function bounceBack (mc)
    {
    var goBackX = new Tween (mc, "_x", Bounce.easeOut, mc._x, mc.startX,.2, true);
    var goBackY = new Tween (mc, ' FLF", Bounce.easeOut, mc._y, mc.startY,.2, true");
    }

  • Problem slider disappears / Drag and Drop does not work

    Hey everybody,

    I have an urgent problem.

    Three butterflies are supposed to be slipped into an object.  My custom cursor is a kind of net to catch these butterflies.


    For the cursor, I have this code:

    cursor_mc.StartDrag ("true");
    Mouse.Hide ();

    My drag and drop code is:

    cursor_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    redbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    violetbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);
    yellowbutterfly_mc.addEventListener (MouseEvent.MOUSE_DOWN, startMove);

    cursor_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    redbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    violetbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);
    yellowbutterfly_mc.addEventListener (MouseEvent.MOUSE_UP, stopMove);


    function startMove(evt:MouseEvent):void {}
    redbutterfly_mc.StartDrag ();
    cursor_mc.StartDrag ();
    violetbutterfly_mc.StartDrag ();
    yellowbutterfly_mc.StartDrag ();
    }

    function stopMove(evt:MouseEvent):void {}
    redbutterfly_mc.stopDrag ();
    cursor_mc.stopDrag ();
    violetbutterfly_mc.stopDrag ();
    yellowbutterfly_mc.stopDrag ();
    }

    But when I'm clicking on a butterfly my cursor stops to move and stay on the throttle position, that I'm dragging. After a fall, there is no cursor at all so we don't know where the mouse is currently located.

    Anyone know why it does not work? I am currently working with a mousefollower, because right now, it's the only way it works...

    The mousefollower code is:

    addEventListener (Event.ENTER_FRAME, enterFrameHandler)

    function enterFrameHandler(event:Event):void {}
    cursor_mc.x += cursor_mc.mouseX / 4;
    cursor_mc.y += cursor_mc.mouseY / 4;
    }

    But now I have the problem that only the Yellow Butterfly moves even if I'm clicking on red or purple...

    Please help me! Thank you in advance!

    Try to use the following code to manage the cursor_mc...

    Mouse.Hide ();
    cursor_mc.mouseEnabled = false; keep the cursor to interfere
    this.addChild (cursor_mc); to place the cursor at the highest level

    function moveCursor(evt:MouseEvent_=_null):void {}
    cursor_mc.x = mouseX;
    cursor_mc.y = mouseY;
    }
    stage.addEventListener (MouseEvent.MOUSE_MOVE, moveCursor);

    moveCursor(); to locate initially mouseover

  • Can you "Disable drag and drop" in Windows 7?

    is there a method to DISABLE drag-and - déposer?

    Hello

    You need to carefully examine the results when you disable a base like the Drag and Drop feature.

    Some examples of functions that may be affected:

    • In many programs, you would be no longer able to drag and select a block of text to copy.
    • It would be impossible to drag a window to another location on the screen.
    • You cannot drag an icon on the desktop for the re - position.
    • In Windows 7, you would be no longer able to drag icons pinned in the taskbar for the re - position.
    • In other programs, you would not be able to drag the mouse to select multiple items.
    • With some third-party utilities that use the "sliders" to make adjustments, you wouldn't be is no longer able to drag the sliders.

    Most users want to disable drag and drop because they have accidentally drag and drop an element to an unknown destination.

    What you can do, without disabling completely the drag and drop functionality is to adjust the threshold to slide with a registry change. This will change the distance that an object must be moved before a drag is initiated.


    WARNING:
    always to the top of the resistry before making any changes. To do this in the registry editor, select file/export. In the scope of the export, all options you select. Save the file to the desktop. If something goes wrong, you can right click on this file to restore the registry.

    Press the button of the Windows Logo + R to bring up the run dialog box. Type regedit.exe in the Open box, and then click OK.

    Navigate to the following key.

    HKEY_CURRENT_USER\Control Panel\Desktop

    In the right pane, find the following.

    DragHeight and DragWidth. These two values will have a value of 4data.

    Right-click each of these values and select Edit.

    In the value data box, type 20.

    Click OK.

    You will need a Log Off/Log on to see the results.

    Test the new setting to see if it works for you. If 20 does not work for you, increase the value 30, etc., until you find the setting that your satisfaction with.

    Reset these values back to 4 returned it all back to the default value.

    Concerning

  • Drag and drop, 1 share of different sur-succes drag Source, 4 Drop target, for each. Is this possible?

    Hello.

    I created an infographic of type board game and wants that the participant to be able to enter the game room, then drop it into different spaces on the Board, each holding to another slide. I need interaction drag - déposer so that they can pick up and drop the piece. Now, what I need is for each target to have a different action, but even if I add each one to a different group, if I change an action for one, that it applies the change to all drop targets.

    Is there a way to get around this?

    In addition, once / if possible, I would like to add a "back button" on each of these slides and would need when the participant returns to the boardgame slide, they can move the piece to a different drop target to read the following description. I think that the best way to do this would be to make all the "wrong" answers, while the game piece is not stuck once they have fell on a drop target "correct." Please correct me if I'm wrong.

    If I understand you correctly, I think that I thought about it.

    1. Create your Drag and Drop, as you would normally
    2. In the Panel of Drag and Drop, select the Options tab
    3. Click on the button set the correct answers
    4. The value of each drop target to have the source of displacement of the source (you must choose the sequence in the Type drop-down list)
    5. Create the slides that you want to display for each drop target
    6. Select one of the drop targets
    7. Go to the Format of the Panel Drag and Drop tab
    8. The Actions of the object... a button click
    9. In the action column, select go to slide, and then select the appropriate slide
    10. Repeat steps 6 through 9 for each target deposit
    11. Overview of the project

    I did a quick test and it seemed to work according to the settings you said earlier.

Maybe you are looking for