17 Replies Latest reply on Aug 15, 2008 4:14 PM by kglad

    Drag and Drop exercise

    naklar
      Hi. I am a language teacher and completely new to Flash. I have designed a drag and drop exercise with textboxes that I converted into movie clips.
      One set of textboxes are empty and are the 'target' textboxes.
      The other set of textboxes are exactly the same size but have writing in them. I have attached the following action script to the moveable textboxes:

      While I have succeeded in making the textboxes move, they will not drop into the 'target' textboxes and stay there. Any idea, why?
        • 1. Re: Drag and Drop exercise
          kglad Adobe Community Professional & MVP
          you mean you clicked on the movieclip that contains your textfield and attached that code to your movieclip?

          if yes, use _droptarget.
          • 2. Re: Drag and Drop exercise
            naklar Level 1
            Thank you so much for your help! You understood me correctly - the actionscript is attached to the textbox (movie clip) with the textfield. I have tried what you have suggested, i.e. put an underscore before the drop but it still does not work. Now the code looks like this:
            Is that what you meant? Thanks again for your help!
            • 3. Re: Drag and Drop exercise
              kglad Adobe Community Professional & MVP
              yes, that's correct. but you have a path error to headtarget. use:

              if(eval(this._droptarget)==_root.headtarget){
              • 4. Re: Drag and Drop exercise
                naklar Level 1
                Hi. Thanks again for your help! I have changed the code but it still does not work. When I originally drew the textboxes, I started off with the empty one (target box) and then copied it onto another layer and added the text. Could that have altered the size? They look the same size when I put them on top of each other. Anyway, the code I have now used looks like this. Is that correct?
                • 5. Re: Drag and Drop exercise
                  kglad Adobe Community Professional & MVP
                  then you're not dropping your dragged movieclip onto _root.headtarget. use the trace() function to see your error.
                  • 6. Re: Drag and Drop exercise
                    naklar Level 1
                    hello kglad. I am sorry to take up so much of your time! Unfortunately, you are dealing with someone who is very ignorant. What do you mean by saying 'use the trace()'. Where do I put it? Does it go somewhere in the original actionscript?

                    Thanks again for your help.
                    • 7. Re: Drag and Drop exercise
                      kglad Adobe Community Professional & MVP
                      try the following. what you see in the output panel (after dropping onto the target movieclip) is what you should be testing against.

                      • 8. Re: Drag and Drop exercise
                        naklar Level 1
                        Hello again. thank you so much for your patience! I have done what you suggested and the following message came up in the output panel. Does that mean anything to you?
                        • 9. Re: Drag and Drop exercise
                          kglad Adobe Community Professional & MVP
                          that means your dropping onto a child movieclip of _root.headtarget. give that child an instance name and use that instead of _root.headtarget in your if-statement.
                          • 10. Re: Drag and Drop exercise
                            naklar Level 1
                            Hi. I am so sorry - I just don't understand what that means. When I first converted the target textbox into a movie clip, I gave the target textbox an 'instance name' which was 'headtarget'. What would the alterations look like? Would I have to change the whole code? Excuse my ignorance!
                            • 11. Re: Drag and Drop exercise
                              naklar Level 1
                              Hi. I am so sorry - I just don't understand what that means. When I first converted the target textbox into a movie clip, I gave the target textbox an 'instance name' which was 'headtarget'. What would the alterations look like? Would I have to change the whole code? Excuse my ignorance!
                              • 12. Re: Drag and Drop exercise
                                naklar Level 1
                                Hi. I am so sorry - I just don't understand what that means. When I first converted the target textbox into a movie clip, I gave the target textbox an 'instance name' which was 'headtarget'. What would the alterations look like? Would I have to change the whole code? Excuse my ignorance!
                                • 13. Re: Drag and Drop exercise
                                  kglad Adobe Community Professional & MVP
                                  double click on the target moviecilp. click on your textfield. in the properties panel assign that textfield an instance name. use that in place of instance9.
                                  • 14. Re: Drag and Drop exercise
                                    naklar Level 1
                                    Hello kglad. Before I started this drag and drop exercise using textboxes, I followed a tutorial which I found on another flash website. I was taught how to design a drag and drop game for which I drew 4 different shapes. Then, I copied those 4 shapes and put them onto another layer. One set of shapes was to be the target shapes, the other ones were draggable. I used the code you can see below. This game worked fine - when I dragged the shapes over the correct targets, they stayed there. I then tried to replicate the same idea (using the same basic code but changing the instance names) but instead of drawing shapes, I used textboxes. Unfortunately, I still can't get this to work. Is there a fundamental difference between shapes and textboxes?
                                    • 15. Re: Drag and Drop exercise
                                      kglad Adobe Community Professional & MVP
                                      there is no fundamental difference.

                                      but you're not dropping where you think you are. use the trace function again (and learn to use the eval(xx._droptarget) function so you can see and use complete paths).
                                      • 16. Re: Drag and Drop exercise
                                        naklar Level 1
                                        Hi kglad. Thank you very much for all your time and effort. I feel that I am completely out of my depth here and need to do some extra reading in order to understand what you are telling me. I'll be back though once I have mastered the basics! Thanks again for all your help!
                                        • 17. Re: Drag and Drop exercise
                                          kglad Adobe Community Professional & MVP
                                          you're welcome. but i'd like to encourage you to use that trace() function. you can learn all sorts of things with it.