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.

Tags: Adobe Animate

Similar Questions

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

  • match, drag and drop the game

    Hello

    My name is Nikola and I am beginner with ACE

    Here's the thing:

    With the help of a tutorial I created a "game", where the user selects objects, it drags and it falls on the correct shape/color/object. Tutorial is based "1 to 1", so you can match an object and a target only.

    Now I have several objects and a target on which I can drop.

    Example:

    TARGET: square blue

    OBJECTS: Circle Blue Star, blue, etc.

    I'm stuck with Instance and Movie clip names since they must be unique, and the code itself works on the principle of the names Peel - object: name, target: 'target' + object name.

    flash1.jpg

    Here is a code for the option "1 to 1":

    var objectoriginalX:Number;

    var objectoriginalY:Number;

    shape_mc.buttonMode = true;

    shape_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);

    shape_mc.addEventListener (MouseEvent.MOUSE_UP, dropObject);

    shape2_mc.buttonMode = true;

    shape2_mc.addEventListener (MouseEvent.MOUSE_DOWN, pickupObject);

    shape2_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) {}

    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;

    } else {}

    Event.Target.x = objectoriginalX;

    Event.Target.y = objectoriginalY;

    }

    }

    I hope I was clear,

    Thank you

    Nikola

    for your special example give all corresponding instances an identical letter to foreground:

    as: bStar, bSquare, specialist for all blue shapes and gStar, gHeart etc. for all those green... you get the idea

    then change your function

    function dropObject(event:MouseEvent):void

    {

    event.target.stopDrag ();

    check if the leader for two Sprites letter is the same

    If (testIfMatch (event.target.name, event.target.dropTarget.parent.name))

    {

    event.target.removeEventListener (MouseEvent.MOUSE_DOWN, pickupObject);

    event.target.removeEventListener (MouseEvent.MOUSE_UP, dropObject);

    event.target.buttonMode = false;

    }

    on the other

    {

    Event.Target.x = objectoriginalX;

    Event.Target.y = objectoriginalY;

    }

    }

    function testIfMatch(_drop:String,__target:String):Boolean

    {

    If (_drop.substr (0, 1) is _target.substr (0, 1))

    {

    Returns true;

    }

    on the other

    {

    return false

    }

    }

  • 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

  • I've lost the ability to copy files on my CD player. When I drag and drop, the only authorized action is 'move' and it does not work.

    I've lost the ability to copy files on my CD player.  When I drag and drop, the only authorized action is 'move' and it does not work.   I tried press and hold the CTRL key while dragging, and when I do that all the other disks show "copy" as the default action, but when I hover over the action CD player available only changes to 'pass '.   I ran the Microsoft Troubleshooting tool for CD/DVD players and he said that the media were not writable, but there is a blank CD in the drive.  Any ideas on how to solve this problem?

    Thanks, but the cd/dvd drive works well - I can burn a cd with windows media player for example.  the problem is that I can't copy files to it.   I can play CDs (haven't checked the DVD).  I can not do and could do before, is doing drag and drop files on it.  The only authorized action is "move".   This happens even when I click CTRL + do drag.   I can copy it to any other player, but the CD player, and when I hover over the "exemplary" drive CD goes to 'move '.

    have you tried using a different suite of cd/dvd burning?

    Imageburn is free and easy to use: http://download.imgburn.com/SetupImgBurn_2.5.7.0.exe

    There may be something to play with your access keys if you have a (ie., wirekeys)

  • codesnippent createjs equivalent of flash as3 drag and drop the code snippet

    AS3 deafult code snippent for drag and drop

    circle.addEventListener (MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);

    function fl_ClickToDrag_3(event:MouseEvent):void

    {

    circle.startDrag ();

    }

    stage.addEventListener (MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);

    function fl_ReleaseToDrop_3(event:MouseEvent):void

    {

    circle.stopDrag ();

    }

    I just tried to convert this code createjs. but my code does not

    / * js

    var t1 = this;

    {circle.addEventListener ('mousedown', function (e)}

    {stage.addEventListener ('stagemousemove', function (e)}

    T1.x = stage.mouseX;

    T2.y = stage.mouseY;

    });

    {stage.addEventListener ('stagemouseup', function (e)}

    e.target.removeAllEventListeners ();

    });

    });

    */

    are you trying to drag and drop the circle?  If so,.

    var tl = this;

    tl.circle.addEventListener ("mousedown", downF)

    function downF (e) {}

    stage.addEventListener ('stagemousemove', moveF);

    stage.addEventListener ('stagemouseup', upF);

    };

    function upF (e) {}

    stage.removeAllEventListeners ();

    }

    function moveF (e) {}

    TL. Circle.x = stage.mouseX;

    TL. Circle.y = stage.mouseY;

    }

  • Drag and drop the image in 2d image

    Hi all

    I am trying to apply a little magic "MS paint" for dialogue of the customer. I want to be able to drag and drop into a 2d image control. Ideally, I wish I could it move and resize once it is there, but let's start with the first part - how to do drag and drop of for example the Office on the 2d image control. The rest is nice-to-have but not necessary.

    I saw a smart example on here by using a transparent control of path, but will not cut here (I have other events related to this area of the image, for example right now, I have a double-click event, add text to the image).

    Thanks for all the ideas... I looked briefly using the API (i.e. nodes Builder) windows but it having the dragons.

    It is not terribly difficult to get these events with the picturebox. You just register for events like I did with the dragdrop event, can it treat appropriately in the structure of your event.

  • Drag and drop the textfield

    Hello.  I'm looking for the design of a few text fields.  What I want to do, it is open a flash document, add a text field and save it as a swf file.  I then have to load these swf using xml and provide drag and drop functionality.  Is it possible to record only a text field, with no experience or anything like that?  So if I add a text field to a document set to 320 by 280 and save the swf when I load in my document, I want not just her either 320 in 280.  I just want it to be the text field.  Can I do this?

    see you soon

    No, but you won't see any difference between what is really happening and what you want.  the only difference is that if you want to refer to the textfield, you will use the content property of your charger to the main timeline of the loaded swf file to reference and use the dot notation can reference the textfield object.

  • I would like to be able to drag and drop the names of folders to categorize.

    With Thunderbird, folders currently appear in the order they are created. I'd like to be able to drag and drop to a new location so my frequently used address is near the beginning and those less-used at the end. Tyty

    No problem. Add on even made records and accounts.

  • I want out emails in folders of ordinary files, but when I drag-and-drop, the "modification date" gets changed. How I can still see the date?

    To archive my e-mail files until I decided to switch to Thunderbird, I create regular folders in windows and drag and drop emails to outlook express in the appropriate folders. The "update" column displays the original date of the email... which is what I want to do with Thunderbird. In my view, that he treats it as a new file created today... that is not good for my archiving system of these professional work files that I need to find often in approximate date.

    I understand the forum that it is by default in Thunderbird. There is an add-on that can do what I'm doing?

    Thank you in advance,
    Netwon

    I think the reason what OE is the original date because each message is stored in a single file, while TB stores all messages in a folder in a file, an mbox file. Thus, when you save a message as a single eml file, its 'modification date' corresponds to the eml file date was written in the mbox file.

    You can find the ImportExportTools add-on useful because it allows you to add the date of the e-mail eml file name when enamel is exported ("Save selected messages" of the message right-click menu).

  • Drag and drop the email from windows to the folder my documents

    I am trying to drag and drop an email from Windows mail to a folder in my documents each time I do I have an option to copy and replace or do not copy. I just want to copy it here is another option or I can change to get it to copy the settings. I'm sure that once there was before me a third option so that it can be copied, can someone help me please.

    Drop into a different folder itthere and renmae before moving on to the final
    folder.
     
    --
    ..
    --
    "SS0001" wrote in message news: f9a3b155-6263-4000-89c 0-596bcea9a814...
    > I get emails from the same source, on a weekly basis and the program
    > think I want to update the existing emails with new emails, but I just
    > to add new emails to the existing e-mail file, make
    > you know how I can fix this?
     
     
  • Drag and drop the LARGE icons

    When I drag and drop a file or a folder in an Explorer window, the icon attached to the mouse pointer is HUGE and gene to see where I am a fall! Is it possible to change this behavior?

    Thank you!

    Thank you, Andre. What seems to do is change the appearance of a window of the Explorer when it is moved - it makes the contents of a window disappear until you drop it somewhere. I am concerned mainly with the HUGE icon that appears when I right-click on one or more files and then try to have them slide somewhere. The large icon, it is difficult to see where I am dragging to. For example, if I want to move a file in a specific folder it makes it difficult to read the folder I want to put the file.

    Using your tip, I found a solution that works for me, but maybe not to everyone's taste. If you go to advanced system settings > performance > settings then uncheck "Use Visual styles on windows and buttons" makes things look more like Windows XP. I prefer the simple XP look in any case so that the solution works for me. The icon HUGE should simply be part of the visual style Windows 7 - I couldn't find any other way to change this.

    Thanks for your help!
    Mark

  • 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.

  • Drag and drop the interactive report

    HY!

    For an interactive report, I would like to implement and drag to order lines.

    It's a request complex abandoned behind the report (joints, ect.)

    I need an element hidden like this

    apex_item.hidden(1, rowid) AS Sort
    

    The problem is, that rowid is not here (ORA-00918: column ambiguously defined).

    Because of this article, I'm sure that the joints in my query are problems

    ORA-00918: column ambiguously defined

    But I need the rowid for the sorting process.

    How to implement Drag and Drop, I learned from here:

    Read the Article - Drag & amp; amp; Drop the rows in a table

    Does anyone know of a workaround?

    Thanks for your help!

    ILB.

    Hello

    You can do also, update for example the primary key.

    In the table of the witch you have the column where you store the sort order?

    Use this table for example name as apex_item.hidden (3, ENDGUELTIGEWARTELISTESORT.rowid)

    Kind regards

    Jari

Maybe you are looking for

  • El Capitan upgrade crash & loss of backup Time Machine

    I have a 2008 MBP running Yosemite and back up to a Time Capsule. Last week, I noticed weird problems with connectivity and slow performance. Last week, I started receiving messages that the Time Machine backup failed. I decided to upgrade to El Capi

  • Problem of volume with Satellite Pro L630

    HelloBrand new on these forums so forgive me if I am in the wrong part of the forum.My L630 bought 19 November 2011, and has downgraded the OS XP Pro. Problems with the volume that is barely audible when full! Is there than some tweak I can do to imp

  • Keyboard problems after upgrade to Windows 10

    Hello I have problems with my keyboard as by chance after I had updated to windows 10. Right now my "6" does not work and when I press '5' key he made just the following '5666666666666666' and keep repeating 6s forever. If I press the left button dow

  • Restore the Image of the camera target in VBAI

    I use Vision Builder AI 2012 with Smart camera NI1772C.  I can create target camera Image (Menu > target > create a target Image) but is it possible to restore the image on the camera?  The image is similar to PC save the image that can be safely sto

  • Need of Win 7 (32 bit) Intel HD Graphics driver for HP 14-d008tu laptop

    I had the graphics card driver Intel HD for Win 7 (64-bit) and now the HP Support and drivers! But I need display driver for Win 7 (32 bit). Please let me know how I can get this driver? If you need more description, then pleae let me know. Thank you