Drag and Drop Game - AS2

Hello

I do a drag and drop game for young children. The child must put the plant proper parts for example of the stem in the right place.

I did the coding for it, but there is no result, the child can easily just put the wrong party at the wrong place and nothing will happen.

How will I be able to provide a result informing the child if it is in the right place or not?

Thank you

This is normally down to assess what the object is deleted, what can be done using the _dropTarget property.  "Try Google search using terms such as"AS2 _dropTarget tutorial"or AS2 Dran and Drop tutorial" and you should be able to find examples explaining how it's done.

Tags: Adobe Animate

Similar Questions

  • Drag and drop in as2

    Hello

    I want to drag an image "on the press" function. When the function function tap is called first the image moves according to the registerpoint and starts to slide. I want to limit his movements. It should start up make drag from where I clicked. Help, please.

    the first parameter to startDrag() is a Boolean value, you want the value false

  • Drag and drop the game. splice method does not work on the table

    Hello

    I have a drag and drop game. You listen a sound for 'bread' peculiarities, you switch to slide that mc in a box. If it's the right object I want to delete as mc and splice table so it isn't select this object more.

    However I notice two things.

    When I splice (0) a specific item - so nothing works.

    When I connect the indexed element cuurent IE: the last element to get right - it is not actually delete it table.

    I highlighted the parts of key code.

    private function placeBubbles (): void
    {
    var nextX:int = 0;
    for each (var: bubble in bubbles)
    {
    bubble.buttonMode = bubble.useHandCursor = true;
    bubble.addEventListener (MouseEvent.MOUSE_DOWN, dragHandler);
    bubble.addEventListener (MouseEvent.MOUSE_UP, checkDrag);
    Bubble.x = 0 + nextX;
    Bubble.y = 300;
    nextX += 100;

    addChild (bubble);
    }
    nextGameRound();
    }

    private function nextGameRound (): void
    {
    currentIndexArray = int (Math.random () * bubbles.length);
    currentBubble bubbles = [currentIndexArray];

    currentBubble.playSound ();
    }

    private void checkDrag(e:MouseEvent)
    {
    e.currentTarget.stopDrag ();
    If (this.currentBubble.hitTestObject (this.box))
    {
    If (currentBubble & & currentBubble == e.currentTarget)
    {
    currentBubble.visible = false;
    trace ("Right");
    Bubbles.splice (currentIndexArray);
    Bubbles.splice (0);

    trace (Bubbles);
    nextGameRound();
    soundCorrect.play)
    }
    }
    on the other
    {

    TweenLite.to (e.currentTarget, 1, {x: xIni, y: yIni, ease:Strong.easeOut, onComplete:onFinishTween}) ;// - If you want something happens on the ending of tween - good idea while children must wait})

    }
    nextGameRound();
    }

    the splice() method accepts two arguments.  the first is the index of the item to delete (start) and the 2nd argument is the number of elements to remove.  in your situation, you should use:

    Bubbles.splice(currentIndexArray,1);

  • 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");
    }

  • How to play a sound on drag-and - drop?

    I have been asked to create a drag and drop game for College and I want to make sure that when an object is selected to the top/clicked on will play a little 'pop' sound and when it is placed successfully on a target, it will play a slightly different sound of "pop".

    I am using ActionScript 2.0 in Flash CS5.5.

    I've got the drag-and - déposer done, I just need to add the sound equivalent. I saw a few tutorials, but they are much too vague for me.

    Look at using the Sound class.  Google search using terms like "AS2 his tutorial.

  • Drag and drop leading to variations in printing color

    We use CS5 on Mac OS x 10.7.5. We create our files in InDesign and PDF export. When all files are made our users select any PDF document files and drop them in the queue of our Ricoh color copier. We have noticed that when you print this way, PDF files are coming up with changes to the colors. If we open the PDF files in Acrobat and print to the copier of the application, the color is correct.

    I thought that by dragging and dropping maybe we were absent on the color settings that are used by the printer when we print of Magnatune, but I used the method of the slide / move on the original InDesign file and there was no change in color, only in the PDF file. Then I realized that InDesign is actually open the file in the background during the move and process of the fall (as evidenced by the temporary files that appear on my computer as it prints them.) and what we put in the print dialog box in InDesign is stored in the document. By example, if I print separations in InDesign and save my file with this setting, and then when I drag and drop the Indesign file I get separations, but not the composite file. So my theory is now that perhaps Acrobat does not save the printer specific settings file, but rather that they are apply only when we print from the application.

    I just discovered the printing Acrobat batch functionality and have set up an action to do and which works very well - no color change, but just curious now why the method slip - déposer did not work as expected.

    Anyone had experience with this, or have any other theories?

    Thanks in advance for any input.

    Interesting. I don't know exactly what is happening behind the scenes, but my suspicion is that this is not at all using Adobe technology, but uses Apple built in manipulation of PDF. It is not so sophisticated in Acrobat. And there are also ambiguities in PDF format that allows two programs, both valid, to print in a different way.

    You can check if it is the technology of Apple by printing a file to preview. If the color of the drag-and-drop game, it is likely Apple technology is used for printing. What is the 'right' is of course another question!

  • Drag and Drop Error1010 of the time?

    I have a drag and drop game that uses arrays for targets.  I have a property on the table of "permitted" so that I can have 4 zones "targets".

    However, I had a problem in the sense that I kept getting an error 1010 due to the use of the authorized property (if I dropped the mc outside the target, it was likely that I would see an error 1010).

    I realized that I had to add my property 'allowed' to all my other movieclips, and it works most of the time.  However, it seems that if I drop my clips on the border of an another movieclip, I get error 1010.

    I applied my property 'allowed' to everything that I could find, event 'root' (due to some images that were also causing the error 1010) and this continues to be.

    Any ideas?

    so each target has a permitted ownership which is the array of authorized interrupted movieclips?  If so, which should cause no problems.  in your drop listener function:

    function dropF(e:MouseEvent):void {}

    {if (MovieClip (e.currentTarget). DropTarget.Allowed)}

    {if (MovieClip (e.currentTarget). {(DropTarget.allowed.IndexOf (e.currentTarget) >-1)}

    This is allowed dropped target

    } else {}

    wrong target

    } else {}

    fell not on any target

    }

    }

  • How to rotate the movieclip with drag and drop?

    Hello everyone,

    I work with drag and drop game.

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

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

    Can someone give me a solution for this?

    var isDrageen:Boolean;

    var lastX:Number;

    var derriГЁre: Number;

    var dragX:Number;

    var dragY:Number;

    stage.addEventListener (MouseEvent.MOUSE_DOWN, down);

    stage.addEventListener (MouseEvent.MOUSE_UP, up);

    stage.addEventListener (MouseEvent.MOUSE_MOVE, mov);

    function down(e:MouseEvent):void {}

    isDrageen = true;

    lastX = mouseX;

    derriГЁre = mouseY;

    }

    function up(e:MouseEvent):void {}

    isDrageen = false

    }

    function mov(e:MouseEvent):void {}

    {if (isDrageen)}

    dragX = mouseX-lastX;

    dragY = mouseY-derriГЁre;

    MC.rotationY += dragX/1.65;

    MC.rotationX += dragY/1.65;

    lastX = mouseX;

    derriГЁre = mouseY;

    }

    }

  • Drag and Drop point sticky

    I have created a drag and drop game for K-2 classes and two of my pieces with the mouse stick when the user clicks on. I'm not sure what the problem is that I used the same code for all my parts.

    The pants1_mc and the glasses_mc are the problems.

    I tried your script and all the elements of fact the same - they stuck with the mouse on MOUSE_UP until I removed 'true' to the line that reads event.target.startDrag (true);
    See if removing real help for you.

  • Drag and drop on the AS2 grid

    I want to create a grid where I drag and fall to her points n Save, do I pull the rack forward myself and do a lot of media (as if I had to do an inventory?) or is there a code I can use.

    I'm quite fine with as2, but I never took the time to really get into the tables. I come up with my own solutions, but I want to do it the good sense.

    for the generation of ex.sims mode.

    anyone interested to help me with my game also?  Doesn't hurt to ask.

    who does not resemble a drag and drop.

    But if you want to attach something to a clicked cell, do it.  Flash will know which cell was clicked the same way, he knows which button in a list of several buttons were clicked:

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

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

    var mc:MovieClip=this.attachMovie("cell_mc","cell_"+j+"_"i,this.nextHighestDepth());

    mc.colNum = j;

    mc.rowNum = i;

    MC._x = j * mc._width;

    MC._y = i * mc._height;

    {mc.onRelease = function ()}

    No matter what

    }

    }

    }

  • Drag and drop the game - add your comments

    Hello

    I created drag and drop the game:

    If the player, drag the object to the correct target - snapping to the target, else it returns to the original location.

    My question:

    I want to add sound (such as feedback) when hanging to the right target.

    What should I write in the code?

    Help, please

    Thank you (-):

    (I added the code and the printscreen)

    star.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

    function fl_ClickToDrag(event:MouseEvent):void

    {

    star.startDrag ();

    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

    function fl_ReleaseToDrop(event:MouseEvent):void

    {

    If (star.hitTestPoint (targetstar.x, targetstar.y))

    {

    Star.x = targetstar.x;

    Star.y = targetstar.y;

    }

    else {}

    Star.x = 692;

    Star.y = 232;

    }

    star.stopDrag ();

    }

    square.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);

    function fl_ClickToDrag_2(event:MouseEvent):void

    {

    square.startDrag ();

    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);

    function fl_ReleaseToDrop_2(event:MouseEvent):void

    {

    If (square.hitTestPoint (targetsquare.x, targetsquare.y))

    {

    Square.x = targetsquare.x;

    Square.y = targetsquare.y;

    }

    else {}

    Square.x = 122;

    Square.y = 266;

    }

    square.stopDrag ();

    }

    create your sound (using the new construction), then apply the play() method to make the sound when your hitTestPoint is real.

  • AS2 Drag and Drop - completion response

    I do a drag and drop alphabet learning game. There are 27 Movie Clips (letters) in total that are able to drag.  I made sure 12 Movie clips will drop in a specific DropZone, while the rest will just snap back to their original position.

    I want to do is create a completion response which moves to a separate screen 'Good Job!' when all 12 Movie Clips have been droped in the DropZone.  How can I do this?  I searched online for more help, but nothing seems to be particularly relevant.

    Thank you!

    Avoid putting code "on the" points at all costs... you will learn a bad habit if you start to do that.

    What you have would be something like the following.  I don't know if this code refers to the 12 pieces that you mention, but I hope you can see the logic and apply for them.

    var dropCount = 0;

    {food1_mc.onRelease = food1_mc.onReleaseOutside = Function ()}

    stopDrag();

    If (this ._droptarget == ' / DropZone4 ') {}

    this.onTarget = true;

    _root. DropZone4.gotoAndStop (2);

    dropCount += 1;  Add 1 to dropCount

    if(dropCount == 12) {}

    gotoAndStop ("goodjob");  go to the section called goodjob

    }

    } else {}

    this.onTarget = false;

    _root. DropZone4.gotoAndStop (1)

    }

    }

  • AS2 drag and drop a hidden content of video for loadMovie

    In the main content, when I have a clip like this a1.a2.a3 all in a3 within a2 and a2 within the a1 and a2 is a clip of masked layer.

    I can drag and drop the hidden content (while still remain a1) with like this a1.a2.onPress = function () {startDrag (this) ;}  and a1.a2.onRelease = function () {stopDrag() ;}

    but then what I need is a1 stay in the main content, while a2.a3 moved to an external .swf and use loadMovie to call les.swf (a2.a3) into a1, and I can still drag and drop a2.a3 when a1 is still.

    I tried the differetn methods they just does not work.  I've learned that you need to create an another MC inside the a1 as this a1.a4.a2.a3 (while loadMovie clip a2.a3). It works only if I want to drag a1. But if I want to drag hidden content a2.a3 that it still does not work.

    I really need help, this is a project for work.

    Once the upload is complete, apply your code drag to a1.a4, target load containing a2 and his children (after the loading is completed).

  • 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

  • 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