Drag N Drop Behaviour Needed

Hello
I am struggling with this very much. I've found various
examples from other members but none which can do the following.
Here is what I'm trying to achieve - not easy for a novice
like myself:
I have 10 answer boxes and 10 answers, I want the user to
drag the correct answer to the correct answer box.
When the answer is released over the answer box it stays
there.
If it's correct the answer a 'correct 'graphic displays.
If it's the wrong answer a 'wrong' graphic displays.
I've been looking everywhere but can't find any behaviour to
do this.
Any help much appreciated.
Andy

Ask and receive (should be 86 lines of code... watch for
breaks...)
global gWrongRects
property pType,pNumber,pBoxRect, pOrigLoc,pWrongRects
on beginSprite me
--make sure the answer type sprites can be dragged
if pType="Answer" then
sprite(me.spriteNum).moveableSprite=TRUE
else
sprite(me.spriteNum).moveableSprite=FALSE
end if
--this will find out the rect of the box with the same
'pNumber' as
it (i.e. the "correct" box)
pBoxRect=sendAllSprites(#getBoxRect,pNumber)
--this is the loc to snap back to if the answer is dropped
outside of
the boxes
pOrigLoc=sprite(me.spriteNum).loc
--ask all the box sprites to build a list of their loc and
rects
sendAllSprites(#getWrongRects,pNumber)
--set a property to store these values
pWrongRects=gWrongRects
-- reset the list in case it is needed for another srite
gWrongRects=void
end
on endSprite me
sprite(me.spriteNum).moveableSprite=0
end
on mouseUp me
sendAllSprites(#isCorrect,pNumber)
end
--test to see if the answer was dropped on the right box
on isCorrect me,vNumber
if vNumber=pNumber and pType="answer" then
myRect=sprite(me.spriteNum).rect
--see if it is in the correct box
if myRect.intersect(pBoxRect)>rect(0,0,0,0) then
sprite(me.spriteNum).loc=sendAllSprites(#getBoxLoc,pNumber)
alert "correct"
else
--check if it is in one of the wrong rects
wrongRect=0
repeat with iRect=1 to pWrongRects.count
if
myRect.intersect(pWrongRects[iRect][#rect])>rect(0,0,0,0) then
wrongRect=pWrongRects[iRect]
exit repeat
end if
end repeat
if wrongRect<>0 then
sprite(me.spriteNum).loc=pWrongRects[iRect][#loc]
else
--answer must have been dropped outside the bounds of any of
the boxes
sprite(me.spriteNum).loc=pOrigLoc
end if
end if
end if
end
--builds a global list of the loc's and rect's of each
incorrect box
on getWrongRects me,vNumber
if vNumber<>pNumber and pType="Box" then
if voidP(gWrongRects) then gWrongRects=[]
gWrongRects.append([#loc:sprite(me.spriteNum).loc,#rect:sprite(me.spriteNum).rect])
end if
end
--returns the loc of the box associated with the answer
on getBoxLoc me,vNumber
if vNumber=pNumber and pType="Box" then
return sprite(me.spriteNum).loc
end if
end
--returns the rect of the box associated with the answer
on getBoxRect me,vNumber
if vNumber=pNumber and pType="Box" then
return sprite(me.spriteNum).rect
end if
end
on getPropertyDescriptionList me
p = [:]
p[#pType] = [#format : #string, #comment : "Answer or Box?",
#range:["Answer","Box"],#default :"Answer"]
p[#pNumber] = [#format : #integer, #comment : "number",
#default : 1]
return p
end

Similar Messages

  • Itunes won't let me drag-n-drop .m4r files into the 'TONES' library (for ringtones)

    Can anyone help?  I have created ringtones by converting my song to AAC, then shortening it to 40 seconds, then saving it as .m4r file extention.  I have changed my preferences to show "Tones" library in my iTunes.  Only problem is, iTunes won't accept the ringtone when I try to add it.  I tried to add it by grabbing it from Finder and dropping it into iTunes...but nothing adds???  Any suggestions?

    In order to drag and drop, you need to have the box next to "Manually manage..." on the iPad summary pane checked.
    This was changed (in V 10.0?)
    Items dragged to the iPad/iPod will still get copied over, even when not manually managing.
    Select the tabs across top and the dragged items show up at the very bottom under *Manually added*.

  • Drag and Drop In 2 ALV Grids

    I have a report which has 2 ALV grids side by side.  I am able to drag a cell from the left grid and drop it in the right grid.  But I also want to drag a cell from the right grid to another cell in the right grid.  I can't seem to make this work.  Does anyone have any suggestions here? 
    Thanks,
    Jack

    Hi Jack,
    Did you define the drag-and-drop behaviour correctly for both grids? Perhaps you can copy the piece of coding where you define the D&D behaviour, so we can have a look at it.
    Kind regards,
    John.

  • How do I drag-and-drop my Web Bookmarks Folder to a external flash drive? I need to move them from one Mac to another Mac.

    '''Moving Firefox URL Bookmarks from one Mac to another'''
    How do I drag-and-drop my web 'Bookmarks Toolbar' folder from one Mac to an external USB zip drive. Unable to network both Macs and use the migration feature. Must do this manually. Thanks!

    Hi RMcMullen,
    You should look at the [[Backing up your information]] Knowledge Base article. It will give you all the information you need to back up everything so you won't lose a thing.
    Hopefully this helps!

  • I just purchased Time Capsule today.  I ONLY want to use it as an external drive.  I do not need it for Time Machine. I can see the TC in my finder, but when I click on a file or video to drag and drop, I get message that TC can't be modified. Help please

    I just purchased Time Capsule today.  I ONLY want to use it as an external drive.  I do not need it for Time Machine. I need to free up room on my computer. As of now, I can't even load updates. I can see the TC in my finder, but when I click on a file or video to drag and drop, I get message that TC can't be modified. Help please!

    I agree with Kappy.. passing files and especially via wireless is slow as slow.
    Just need to be sure your TC is the new AC model??
    And the OS on the computer is Lion?
    Have you completed the setup of the TC via the utility? You do still need to get internet via the TC so it has to be plugged into the main router..
    Give us the full picture of the network.
    Then we can help you get into it.. whether you should put your files on it is another question.

  • My hard drive crashed on my MacBook Pro crashed and I need to get my CS5 up and running on the new hard drive. I copied what I could onto an external hard drive but when I drag and drop I get directions to uninstall but the uninstall folder I have does sa

    my hard drive crashed on my MacBook Pro crashed and I need to get my CS5 up and running on the new hard drive. I copied what I could onto an external hard drive but when I drag and drop I get directions to uninstall but the uninstall folder I have does says it is an alias that is no longer present. I get error 6. I would like to get my software up and running on the laptop again please

    If you subscribed to iTunes match the songs are kept in icloud. If you didn't but you did save the actual iTunes library folder which should include the music, video, etc.  you should be able to just drag this file back to your machine in the same place and when you open iTunes it will give you a chance to identify the iTunes library folder. 
    You can test this to find out if you saved the media files or not and don't need to attach your nano to do it. 
    You are correct that once you connect the nano it will clear the existing files from it and sync it with the new iTunes library. 
    If you don't have the media files i'm not sure if/how to get them back on a windows ipod.  I have everything backed up regularly because of the horror stories I have seen & heard.

  • Help needed in drag and drop of Flex tree

    Hi,
    We have an application which allows drag and drop between
    multiple
    trees and lists.
    Here are the steps I follow to refresh on drag and drop:
    1. Dispatch a custom event which calls server.
    2. On successful response from server I change the model
    which is
    data provider for the tree.
    3. Then, set a flag which triggers 'invalidateDisplayList'
    and 'invalidateList' for tree (and other listeners).
    4. The tree refreshes fine. But as soon as I drag and drop
    between
    trees again, I get this error in Tree.as:
    TypeError: Error #1010: A term is undefined and has no
    properties.
    at mx.controls::Tree/::updateDropData()
    at mx.controls::Tree/calculateDropIndex()
    at mx.controls.listClasses::ListBase/showDropFeedback()
    at mx.controls::Tree/showDropFeedback()
    The behaviour is weird, sometimes the browser hangs and stops
    responding.
    I am calling 'contentTree.showDropFeedback(event)' in my
    dragOver
    event listener which is triggering error.
    My tree data provider is a custom class which has 'children'
    array
    collection attribute.
    Any help on how to resolve this issue would be highly
    appreciated.
    Thanks in advance,
    Sujatha

    the major restrictions in its implemented only in
    jdk1.1.Why!

  • Help needed in Drag and Drop and  resizing of image icons

    Hi all,
    I'm doing a project on Drag and Drop and resizing of image icons.
    There is one DragContainer in which i have loaded the image icons and i want to drop these image icons on to the DropContainer.
    After Dropping these icons on to the DropContainer i need to resize them.
    I have used the Rectangle object in resizing.
    The problem now i'm facing is when i drag, drop and resize an image icon and when i try to drag, drop a second image icon the first image icon gets erased.
    can any one help me in fixing this error.
    if u want i can provide the source code.
    thanks in advance
    murali

    the major restrictions in its implemented only in
    jdk1.1.Why!

  • I need to play a song on a Keynote presentation, how do I do this ? I use to drag and drop the mp3 in Keynote but it stops playing when the slide move to the other one... how can I make the song keep playing through the whole presentation ? Thanks.

    I need to play a song in a row in a Keynote presentation, how do I do this ? I use to drag and drop the mp3 in Keynote but it stops playing when the slide move to the other one... how can I make the song keep playing through out the presentation ?
    Thanks.

    Drag the file into the audio window in the Document inspector...

  • Hello.... I already loaded logic 9 on my laptop hard drive... I would to load all the samples and loops on an external drive... Do I need to reinstall from DVD's or can I drag and drop?

    Hello.... I already loaded logic 9 on my laptop hard drive... I would to load all the samples and loops on an external drive... Do I need to reinstall from DVD's or can I drag and drop?

    Thank you.... Would you know where they would be on my hard dive? Are they all together?

  • Need clarification on drag n drop

    I need a small clarification on the following requirement.
    User has setup and data entry module. In the setup module, user has the option to select what are the text boxes to be displayed in the data entry screen. After submission, he will get all these fileds when he goes to data entry screen.
    My question is that is it possible to drag and drop the text box to a particular position (may be right, left, middle, top of the screen, bottom of the screen) in the browser during setup?

    is dColors() the only place you're using stopDrag()?  if so, what's the following show:
    function dColors(event:MouseEvent):void {
    event.target.stopDrag();
    trace("dropped",event.target.name,event.currentTarget.name);
    var matchingTargetName:String = "target" + event.target.name;
    var matchingTarget:DisplayObject = getChildByName(matchingTargetName);
    trace(event.target.dropTarget.parent.name,event.currentTarget.dropTarget.parent.name,event .currentTarget.dropTarget.name,"=+",matchingTargetName);
    if (event.target.dropTarget != null && event.target.dropTarget.parent == matchingTarget){
    event.target.removeEventListener(MouseEvent.MOUSE_DOWN, uColors);
    event.target.removeEventListener(MouseEvent.MOUSE_UP, dColors);
    event.target.buttonMode = false;
    event.target.x = matchingTarget.x;
    event.target.y = matchingTarget.y;
      score_s = score_s += 100;
      ScoreS.text = score_s.toString();
    } else {
    event.target.x = objectsoriginalX;
    event.target.y = objectsoriginalY;

  • When I try to move one layer to another layer, my drag and drop won't do it. What do I need to do?

    The drag and drop technique,don't seem to work in my program. is there something I need to configure?

    For an example we will use tab 1 for the old image and tab 2 for the new image. In that the images from tab 1 will be dragged and dropped to tab 2.
    Open two images as per above.
    Click tab 1 to make that the active document if it is not already
    In the layers panel click on the layer that has the image
    In the document window (the canvas) move the cursor over the image, press left mouse button down and drag to tab 2 (don't let go of mouse button)
    The document in tab 2 will become active
    With the mouse button still held down drag the cursor over the center of the document (canvas) {If you wish to center the image on the canvas you may now hold down the shift key while the mouse button is still held down
    Let go of mouse button then let go of shift key
    You should now see two layers in your layers panel. One image is on top of the other so you can not see the bottom image
    You now have a few choices, you can expand the canvas and move the image(s) so they are side by side
    You can add a mask to the top layer and paint away what you don't want
    You can select parts of the background of the top image then delete it
    You can lower the opacity to blend the two images into one
    You can use a blend mode to blend the two images into one
    This apart is totally up to you and if you need any further advice let us know or if you are still stuck, please capture your screen so we can see what you did and have the layers panel open with any collapsed layers expanded.

  • I need to implement Drag N Drop between two tables which saves both records

    I need to implement Drag N Drop between two tables which saves both records in a third page, by using drag n drop.

    check this video http://baigsorcl.blogspot.com/2011/01/drag-and-drop-collection-in-oracle-adf.html

  • Do I need to have data before performing Drag and Drop????

    I have gotten drag and drop working with Swing in JDK 1.4b2 using "URL-based" files instead of operating system native files. The way this was accomplished by creating a wrapper class that sub-classed File and would download the contents of the URL to a temporary file and then initiate a normal drag and drop operation using the normal java file mechanisms. However, when you have a large file, the operation can take too long since I am fronting all of the effort at the start of the drag. I would like to be able to delay the need to produce the bytes/files to give to the operating system until after there has been a successful drop, at which point I can do the heavy lifting and raise a dialog telling them that the action is commencing. As best as I can tell, you must have all of the data BEFORE any operation (which could be a potential design flaw!!)
    So, is there a way to get a hook that there has been a successful drop to a vm-external drop target before the VM gives the data over? Even if I create my own data flavor (which isn't well documented outside of Text types) won't I still run into the same problems? Am I just overlooking something simple?
    Thanks for your help.

    Hello
    I've had the same problem, but take a look at: http://foxtrot.sourceforge.net/
    You can use their API to start the long consuming time job (reading files from the network) and also to paint a progress bar, showing the progress in the Event Dispatch Thread.
    This is how I've solved my problem:
    I've passed a MyTransferable object to the startDrag method of the DragGestureEvent event.
    In the getTransferData method of MyTransferable object (that implements Transferable interface) I've used the Worker.post method of their API which reads the file from the network and updates a progress bar.
    The API lets the Event Dispatch Thread enter but not return from the listener method (getTransferData in my case), instead rerouting the Event Dispatch Thread to continue dequeuing events from the Event Queue and processing them (repaint the progress bar). Once the worker thread has finished, the Event Dispatch Thread is rerouted again, returning from the listener method.

  • New and need help - drag and drop with dynamic text

    So I'm doing this project and as an animator I'm not familiar with the whole action script side of flash
    Okay so far I've managed to create the whole Drag and Drop feature and it works well, the thing is I want to make it so when you drag in object in the correct spot and new text appears, and I need like six different object with the dynamic text. but I have no idea how to integrated it in my code or where I should start!
    So i based myself on some tutorial so theres some code in there that had dynamic text, but not exactly what i wanted
    Your help would be much appreciated!
    This is my code:
    var counter:Number = 0;
    var startX:Number;
    var startY:Number;
    six_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    six_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    five_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    five_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    four_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    four_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    three_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    three_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    two_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    two_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    one_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    one_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    function pickUp(event:MouseEvent):void {
        event.target.startDrag(true);
    reply_txt.text = "";
    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 = "Good Job!";
    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 {
    reply_txt.text = "Try Again!";
    event.target.x = startX;
    event.target.y = startY;
        if(counter == 6){
            reply_txt.text = "Congrats, you're finished!";
    six_mc.buttonMode = true;
    five_mc.buttonMode = true;
    four_mc.buttonMode = true;
    three_mc.buttonMode = true;
    two_mc.buttonMode = true;
    one_mc.buttonMode = true;

    where you have
    xxx.text = ....
    is where you're assigning text.

Maybe you are looking for

  • How to substitute a month abbreviation for the posting period in a query

    Hi, I have a query that lists the Posting Period (0FISCPER3) characteristic in the rows and key figures across the columns.  Is there a way to display the Posting Period as a month abbreviation instead of a number?  So for example, instead of display

  • Adobe says it is installed, but it isn't

    I keep trying to install Adobe Flash Player on my new macbook pro, and it isn't working. It says that it is finished installing, but then it is nowhere on my computer. Help!

  • Sorting problem in BEx/Portal

    Hi all, I am facing a problem while sorting an Infoobject in BEx or in portal. For e.g I am having a PO Status Report  in which I have PO, Trasaction description and calday.Now when I am executing that report in BEx and on right clicking -> Sort PO w

  • Archiving a smartform

    Hi, I try to archive the smartform ZSSFFAKT01 by passing the following parameters to FM. When I have a look at Transaction OMA1 I get an error in the outgoing documents section saying: Content-Repository does not exist. Any ideas, what's going wrong

  • Simple Automation question

    OK, I can't imagine that this is something that Logic missed out, probably just an oversight on my part, but Ive dedicatad some time to this and still no answer, so here goes: I use Logic 8.0, Ive noticed that with the exception of volume level autom