Drag and Drop with snap and response

Ok, first of all I'm new to all of this as I'm just doing some parttime work. I'm trying to make a drag and drop game where the images (imported and made into movie clips with instance names "peg1 - peg7") are to be dragged onto targets (images, made into movie clips with instance names "targetpeg1-targetpet7").
Here's my code and it comes up with two errors -
ReferenceError: Error #1069: Property parent not found on builtin.as$0.MethodClosure and there is no default value.
at Gametake1_fla::MainTimeline/fl_ReleaseToDrop()
Please help!!! Thanks a bunch!
Amy
peg1.buttonMode = true;
peg2.buttonMode = true;
peg3.buttonMode = true;
peg3.buttonMode = true;
peg4.buttonMode = true;
peg5.buttonMode = true;
peg6.buttonMode = true;
peg7.buttonMode = true;
peg1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg6.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg7.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
event.currentTarget.startDrag();
reply_txt.text = "Drag the image to its correct location"
peg1.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg2.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg3.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg4.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg5.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg6.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg7.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
event.currentTarget.stopDrag();
var myTargetName:String = "target" + event.target.name;
var myTarget:DisplayObject = getChildByName("myTargetName");
if (event.target.stopDrag != null && event.target.stopDrag.parent == myTarget){
    reply_txt.text = "Good Job!";
} else {
    reply_txt.text = "Try Again!";
function checkTarget(drag){
if (drag.hitTest(targetpeg1)) {
trace(drag+" has been dropped on greyCircle");
} else {
trace("you missed the target");

use:
peg1.buttonMode = true;
peg2.buttonMode = true;
peg3.buttonMode = true;
peg3.buttonMode = true;
peg4.buttonMode = true;
peg5.buttonMode = true;
peg6.buttonMode = true;
peg7.buttonMode = true;
peg1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg6.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
peg7.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
function fl_ClickToDrag(event:MouseEvent):void
event.currentTarget.startDrag();
reply_txt.text = "Drag the image to its correct location"
peg1.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg2.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg3.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg4.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg5.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg6.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
peg7.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
function fl_ReleaseToDrop(event:MouseEvent):void
event.currentTarget.stopDrag();
var myTargetName:String = "target" + event.currentTarget.name;
var myTarget:DisplayObject = getChildByName("myTargetName");
if (event.currentTarget.dropTarget){
if(event.currentTarget.dropTarget.parent == myTarget){
    reply_txt.text = "Good Job!";
} else {
    reply_txt.text = "Try Again!";

Similar Messages

  • Drag and Drop with snapping

    I'm trying to create a drag and drop map where the country snaps into place on top of it's target. I have loaded all necessary libraries and the dragging works fine. I just need it to snap into it's place. Here's my code...
              sym.$('Peru2').draggable();
              sym.$('Peru_target').droppable({drop: function() {sym.getSymbol("Peru2").play();}});
    And here's the example...
    http://jzdconnect.com/map_drag/map.html
    HELP!

    Since all your assets positions are absolute,you can set the desired top and left values of div your are dragging in the drop callback function.
    Something like
    sym.$('Peru_target').droppable({drop: function() {
    var symbol = sym.getSymbol("Peru2");
    var ele = symbol.getSymbolElement();
    $(ele).css({top:<your value>;left:<your valye>});
    symbol.play();
    Hopefully this helps

  • WAD drag and drop with table and graphs

    Dear Experts
    I create a web template with chart and query.
    I have problem with drag and drop when I change the visualization of
    the template.
    If I create a template with graph open I can add free characteristics
    only if the graph is open. If I want close it, I can only change/substitute the
    free characteristics, but not add one.
    this behavior is opposite if I create the template with graph close: I
    can add free characteristic if the graph is closed, when I open it I
    can only change/substitute the characteristics.
    Is this the correct behavior
    Thank you and best regards
    Elena

    Merci beaucoup!!
    it is also posible in AWT ?
    Message was edited by: roshca181
    [email protected]

  • [SOLVED] Thunar 1.6 doesn't drag-and-drop with the right mouse button

    Hallo all.
    It might be something I've done (though I did delete my ~/.config/Thunar directory before upgrading), but Thunar doesn't let me drag-and-drop with the right mouse button, thus stopping me from copying something instead of moving it, etc. Has anyone else had that too?
    Last edited by GordonGR (2012-12-28 14:34:20)

    Joel wrote:
    anonymous_user wrote:Is it supposed to be with the right-mouse button? I always thought drag and drop was done with the left button?
    Could be right-hand user
    Come on! Read what GordonGR wrote!
    Microsoft Windows, Nautilus, the Haiku Tracker, and probably many other file managers have a feature where, when you right-click or middle-click and drag an icon to a new location, a pop-up menu appears and asks what you'd like to do (Move, Copy, Link). I thought I used to use this feature in Thunar too but it seems to have stopped working in recent versions. Has anyone else had any experience with it?
    EDIT: Here's random blogger talking about the feature in an older version of Thunar: http://jeromeg.blog.free.fr/index.php?p … and-tricks So that's good, I wasn't just imagining the feature.
    Last edited by drcouzelis (2012-12-12 03:45:05)

  • Can't drag and drop nor copy  and past with iMac with OS 10.8.1.

    Can't drag and drop nor copy and past with iMac with OS 10.8.1.  Not with iTunes, MS Word, nor Pages.  No where.  Reboot or relogging in helps for about an hour.  Hard reset worked for a short time. Per Apple support, most likely will reinstall the operation system.  Just wondered if anybody else has run into this.  Did a disk scan, and that was fine.  And did rebooting, holding down CMD+OPT+R, and P..  Deleted all the start up programs.  Checked the internet, no solutions there.  So it all appears to be OS redo time. 

    Do you subscribe to MLB.tv, and if so, did you install the NextDef plug in? If so, read this…
    https://discussions.apple.com/message/19185556#19185556
    I removed the NextDef plug in over 24 hours ago, restarted and haven't had a single issue with drag and drop or cut and paste since.

  • Can't Drag and Drop with a Double Tap using Single Finger in Lion?

    I installed the Mac OS X Lion two days. But I can't drag and drop with a Double tap using Single Finger, which I used to do in Snow Leopard.
    If I choose Three Finger Move, then Swap Between Pages goes back to "Scroll left or right with Two Fingers" that only works with Safari, but doesn't work with Chrome or Firefox.
    I tried literally every setting in Trackpad and also checked if there was a override settings and there is no overrride setting.
    Would be thankful, if you guys could suggest me what to do?
    ======================================
    My Machine Configuration:
    Macbook Pro 13" (mid 2010)
    Intel Core 2 Duo 2.4GHz
    4GB Ram
    Nvidia Geforce 320m
    Mac OS X Lion (Installe on a updated Snow Leopard 10.6.8)

    Hey Serge many thanks for telling me how to do. now its working like previously
    I just cheked the Dragging under Trackpad option and unchecked Three Finger Moves. now I can drag and drop with a double tap using single finger.
    Thank you guys. You are the best

  • Is the drag and drop interaction available for responsive projects in Cp8?

    I created a responsive course but the Drag and Drop button is not active. Is the drag and drop interaction available for responsive projects in Cp8?
    Thanks

    Not yet available for responsive projects.
    On Jul 14, 2014 10:31 PM, "EWC_elearningDev" <[email protected]>

  • Error in drag and drop with a Tree component

    Hello, everybody.
    I'm doing a drag and drop with two trees.
    But, when I drag from a tree to another show this error:
    "oracle.job.RowNotFoundException:JBO25020: View line of oracle.jbo.Key[4.4] key not found in ViewTreeNodeRepository13_71."
    Besides that, in my property SelectionListerner, when I have this line: "#{bindings.TreeNodeRepository.treeModel.makeCurrent}" there is a warning that says: "Reference makeCurrent not found".
    Anyone can help me?
    Thanks!

    Hi,
    +Besides that, in my property SelectionListerner, when I have this line: "#{bindings.TreeNodeRepository.treeModel.makeCurrent}" there is a warning that says: "Reference makeCurrent not found".+
    Don't worry, its a designtime warning because the EL cannot be resolved. MakeCurrent is a method on the FacesCtrl binding equivalent to ADF, which is applied at runtime and not available at design time
    +But, when I drag from a tree to another show this error: "oracle.job.RowNotFoundException:JBO25020: View line of oracle.jbo.Key[4.4] key not found in ViewTreeNodeRepository13_71."+
    In drag and drop, ADF Faces performs the drag. However, the rest of the drop handling is up to the developer. Without any more information of what yur drop handler is doing, this question cannot be answered
    Frank

  • Can't Drag and Drop, or cut and paste

    Weirdest thing - all of a sudden I can't drag and drop, or cut and paste. I fixed permissions, deleted varied preference files and rebooted, reset the permissions on /tmp, etc. and still no go.
    Any suggested avenues to find what the possible problem is, and how to solve (short of reinstalling)?

    On the left side of the browser at the top of the iPhoto window you will see two symbols. The top one looks like a sheet of paper with the corner folded down, the bottom looks like multiple sheets/cards. If you click on the top symbol, you will view thumbnails of the pages in the book; the bottom gives you photos. At the bottom left of the window, there are two buttons above the word "view". Clicking on one button versus the other changes the window to view either one or two pages. This also affects whether or not the pages are locked together in the browser. When you are in page view, you can drag and drop pages in the browser to create the order you wish.
    I hope this helps.

  • Drag and Drop between JTree and Labels in 2 different panes

    Hi,
    I am using JDK 1.4.1 and am trying to implement Drag n Drop between a JTree and JLabels with ImageIcons, both on different panes.
    I got the DnD working fine on the tree. but i cant get to drag and drop the label from the other pane, on the Jtree as a node. I am getting confused with the DataFlavors, and also wonder if there is something else that i have to do for DnD between 2 panes. Can someone give me any leads on this, please? The Panes I am talking about are splitpanes.
    thanks,
    Sri.

    hey thanks Dennis!! I was hoping you would respond to my question, as I have seen a lot of your replies. yes, the example you gave would be helpful. but i am trying to implement this in 1.4.1, with the new drag and drop in swing. and i am getting confused wiht theh data flavors etc.
    my problem at hand is :
    I have a tree on the left pane. i can drag and drop the nodes on the tree itself. (i already did that...no problem). I have Jlabels with imageicons (actually wrapper classes with labels and imageicons) on the right pane. i have to be able to drag these labels to the tree such that they form a node.
    I have one class the NodeSelection class which extends TransferHandler and implements Transferable. i was able to do DnD for the tree using this. I customized the importData method in this.I thought that i can just use the same class to create the transferhandler and transferable, and just use a different implementation for the importData method if the data being dragged is from the label.
    well, my thoughts and ideas were ok...but i can implement it...so they must be wrong ;-)
    Can u please suggest another way to do this. I have a deadline to meet and am stuck here :-( any suggestions or tips or hints would be very helpful and appreciated!!
    Thanks,
    Sri.

  • Drag and Drop Apps to and from Dock, doesn't work for one account?

    Hi there,
    I have 2 accounts on my Macbook, one of them is my main account which is admin and nothing is wrong with it. The second account though is also admin but I cannot drag and drop applications to and from the dock. I can open the program, hold left click down till it pops up with options and in which you can untick Keep in Dock. Which would be fine but as soon as the computer restarts or I log out then in again, the application reappears. Any help or ideas would be much appreciated.
    Note that I have deleted both plist files from library/preferences and I have also enabled parental controls and ticked the allow users to modify the dock option. I also tried downloading Onyx and setting it up through there but it was a no go. Anyway, if anyone has any idea then that would be awesome.
    Cheers

    TheArtieChoke wrote:
     The second account though is also admin but I cannot drag and drop applications to and from the dock.
    Ok, you can drag applications from your Applications and Utilities Folders to make a "alias" (aka shortcut) in the Dock, but if you drag the icon off and drop it, it "poof's" away as your deleting the alias. The program itself isn't in the Dock at all at any time.
    TheArtieChoke wrote:
    I can open the program, hold left click down till it pops up with options and in which you can untick Keep in Dock. Which would be fine but as soon as the computer restarts or I log out then in again, the application reappears.
    Right, when you run a program from where ever, it places a alias icon in the Dock, which you then right click and choose to keep the alias in the Dock which survives reboots and logouts/in as normal.
    If you right click and choose "open at log-in" the program will automatically run when you restart or log back into the account.
    TheArtieChoke wrote:
    Note that I have deleted both plist files from library/preferences and I have also enabled parental controls and ticked the allow users to modify the dock option. I also tried downloading Onyx and setting it up through there but it was a no go. Anyway, if anyone has any idea then that would be awesome.
    I don't see any problem, other than your not knowing the icons in the Dock are aliases.
    You should set the same user controls and preferences on the second admin as the first and your problems should disappear.
    OnyX is a great program, I recommend it highly, but I don't see it fixing your problem in this case. Unless there is something your not being clear on.

  • I can't copy iPhoto to my external hard drive. It will not allow me to drag and drop or copy and paste., I can't copy iPhoto to my external hard drive. It will not allow me to drag and drop or copy and paste.

    I can't copy iPhoto to my external hard drive. It will not allow me to drag and drop or copy and paste., I can't copy iPhoto to my external hard drive. It will not allow me to drag and drop or copy and paste.

    NTFS is your problem.
    iPhoto needs to have the Library sitting on disk formatted Mac OS Extended (Journaled). Users with the Library sitting on disks otherwise formatted regularly report issues including, but not limited to, importing, exporting, saving edits and sharing the photos.
    See this article
    http://support.apple.com/kb/TS5168
    for more. Note also the comment:
    “Additionally, storing the iPhoto library on a network rather than locally on your computer can also lead to poor performance or data loss.”

  • I can't drag and drop or cut and paste all of a sudden! Help

    I can't drap and drop or cut and paste all of a sudden.  I updated my windows suite and ditched the old stuff.  The next day no drag, drop, cut and paste.
    <Email Edited By Host>

    *FireFTP: https://addons.mozilla.org/firefox/addon/fireftp/

  • Drag and drop the text and image

    Hi,
    I need help in drag and drop text and image.
    I am able to drag and drop the text and image in doc but  i want to drag the text in text frame and image in image frame only.
    For this how to get textframe id or is there any other way to do this. Pls help me if anyone know how to do this one.
    Thanks
    Arun

    This thread is pretty old, but this can help anyone in the future:
    To handle a drop in InDesign, you have to implement your own custom CDragDropTargetFlavorHelper. You can find a working example in SDK Sample. Take a look at BasicDragDrop.sdk project in the SDK.

  • My touch pad is no longer responding to hard press downs for drag and drop or copy and paste

    my touch pad is no longer responding to hard press downs for drag and drop or copy and paste ability

    may be a totally stupid question, but how can I tell?

Maybe you are looking for

  • Downloading apps in "third world" countries HELP

    I live in Serbia and bought Ipod touch (2g) in USA. Got new version of software. I wanna dl some free apps like msg and fb. How??? I made Apple ID, but always get lost at some payment and cards stuff. Is it possibly to dl FREE apps with original Ipod

  • Using WHERE command in property loader SQL query

    Hello All, Hopefully this will be a fairly straight forward question. I am attempting to use Property Loader to read in test limits from a SQL database. There are many types of models that need to be tested, each having a unique set of limits. I want

  • Need to us CS2, but not supported on OS 10.8

    I can't afford to upgrade to Adobe Creative Suite whatever and all I have CS2 on my computer. Just upgraded to 10.8, and apparently CS2 is not supported on 10.8. Is there anything I can do?

  • Image gallery issues...

    This image gallery uses the HTTPService control to populate an array which is then used to populate thumbnails and a full image however it does not display properly on the first load. Thumbnails do show up upon a refresh but are not very consistant.

  • Security and privs

    when calling a database level function in oracle forms what permission should i set in database level ? eg....this code developer are using in oracle10g forms. total_record:=total_record+1; SELECT WEB_PRODUCTION.fn_get_finished_opening_stock(V_PRODUC