14 Replies Latest reply on Jun 13, 2007 7:21 AM by Jamesabth

    reset button and movie color change

    funky12345
      hi all

      I have created a drag and drop interaction. i am trying to get the reset button working. But i can't i have attached my code.

      On my main timeline i have a draggers, droppers and actionscript and button layer. The drag and drop is working. however the reset button doesnt, im not getting any error messages either when i preview my code. when i preview i can drag and drop but then when i press my reset button i get nothing. the instance and button name are the same name 'reset_btn'. Almost seems like my button isnt attached to my reset_btn code code. All my code for the drag and drop and reset button lies in a actionscript layer in a frame on the main timeline.

      Also i wanted the object that dragged objects are placed on too to change colour depending on if the person drags the drag object on to the correct object. I have also added the code for this, but when i preview my work it just loops and go through the different colours that i have specfied on the keyframes. I have tried adding a stop(); to the moive clip but then when i preview it. The clip doesnt change colour when i drag and drop an object on to it.

      can anyone help with my two problems. the worst thing is no error messages so dont know what to do.


        • 1. Re: reset button and movie color change
          Jamesabth Level 1
          Post a link to the fla - it is hard to tell wat's wrong here with just part of the code.
          • 3. reset button and movie color change
            funky12345 Level 1
            hi guys

            Thanks kglad for drawing my attention to that. My reset button now works, However when i place my object on the drop zone it should change colour. However the drop zone movie clip just keeps looping and changing colour without anything being dropped on it. However when i do drop an object its works, but during the start it loops. do u know how i can prevent this

            I have added the following line to my reset button code to make it go back to the first colour
            drop1_mc.gotoAndStop(1);

            I have posted up the fla file. hopefully it will make more sense.

            http://homepage.ntlworld.com/unixhome/
            • 4. Re: reset button and movie color change
              kglad Adobe Community Professional & MVP
              put a stop() in the first frame of your drop zone mc.
              • 5. Re: reset button and movie color change
                Jamesabth Level 1
                I have looked at your fla and there is no stop action at the start of the drop1_mc movieclip, but also there in your actionscript you are saying drag2_mc.gotoAndStop(5); and drag2_mc.gotoAndStop(10); and I belive you want to say drop1_mc.gotoAndStop(5); and drop1_mc.gotoAndStop(10);
                • 6. Re: reset button and movie color change
                  funky12345 Level 1
                  Hi Jamesabth

                  Thanks for your feedback, well spotted. I have now addressed this problem. Its amazing how staring at code can make u miss such silly things.

                  thanks once again
                  • 7. Re: reset button and movie color change
                    funky12345 Level 1

                    Hi

                    I having a problem with my drag and drop activity. I have a problem


                    At the momment you can drag text 1 in to box 1 and it changes colour to green(correct) and if you drag text 2
                    to box to it changes to green(correct).


                    However if you drag text 2 in to box 1, box 2 changes red. I would really like box 1 to
                    change to red and the text to remain in the box?

                    Can anyone help with this

                    I have uploaded the fla file

                    I am using flash version 8


                    http://homepage.ntlworld.com/unixhome/


                    • 8. Re: reset button and movie color change
                      Jamesabth Level 1
                      Hi,

                      In the else section of the onRelease event of each of the drag movieclips, replace "drop1_mc.gotoAndStop(10);" or "drop2_mc.gotoAndStop(10);" with the following if() statement:

                      if(this._droptarget) {
                      eval(this._droptarget).gotoAndStop(10);
                      }

                      This checks if the _droptarget property of the movieclip has a value (in other words if the drag movieclip is being dropped on another movie clip) and if it does, then the movieclip that it is being dropped on will gotoAndStop frame 10.

                      If you have other movieclips in your movie, then you may want to use the following if statements instead of the one above.

                      if(eval(this._droptarget) == drop2_mc) {
                      eval(this._droptarget).gotoAndStop(10);
                      }

                      and in the drag2_mc release event:

                      if(eval(this._droptarget) == drop1_mc) {
                      eval(this._droptarget).gotoAndStop(10);
                      }

                      JAMES
                      • 9. Re: reset button and movie color change
                        funky12345 Level 1
                        Hi james

                        Thanks for the feedback. I do have more movie clips i have 13 draggers to build and 13 droppers.

                        I have tried both bits of your code and they do not seem to work for me.
                        • 10. reset button and movie color change
                          Jamesabth Level 1
                          You seem to have switched round the if() statements.
                          See the attach code
                          --
                          If you have many draggers and drop movieclips, then you will have to say (the following example would be in the onRelease event for the drop1_mc movieClip):

                          if(eval(this._droptarget) == drop2_mc || eval(this._droptarget) == drop3_mc ) { // and so on
                          eval(this._droptarget).gotoAndStop(10);
                          }

                          unless you do not have any other movieclips with a frame 10 in them APART FROM DROP MOVIECLIPS. In that case you can just say:

                          if(eval(this._droptarget)) {
                          eval(this._droptarget).gotoAndStop(10);
                          }

                          and this would work in every case without any need to change any movie clip names.
                          • 11. reset button and movie color change
                            funky12345 Level 1
                            Hi James

                            So to be clear if i have 13 clips perhaps i would need to do something like this

                            if(eval(this._droptarget) == drop2_mc || eval(this._droptarget) == drop3_mc
                            || eval(this._droptarget) == drop4_mc )
                            || eval(this._droptarget) == drop5_mc )
                            || eval(this._droptarget) == drop6_mc )
                            etc...
                            )

                            { // and so on
                            eval(this._droptarget).gotoAndStop(10);
                            }
                            • 12. Re: reset button and movie color change
                              Jamesabth Level 1
                              Yes - that would be the safest way to go. That would be the code for the release event for the drag1_mc movie clip, then you would just have to change some numbers around for the rest.

                              JAMES
                              • 13. Re: reset button and movie color change
                                funky12345 Level 1
                                ok thanks....... but a bit confused about the brackets

                                if(eval(this._droptarget) == drop2_mc || eval(this._droptarget) == drop3_mc
                                || eval(this._droptarget) == drop4_mc )
                                || eval(this._droptarget) == drop5_mc )
                                || eval(this._droptarget) == drop6_mc )

                                is the above better or

                                if(eval(this._droptarget) == drop2_mc || eval(this._droptarget) == drop3_mc || eval(this._droptarget) == drop4_mc || eval(this._droptarget) == drop5_mc || eval(this._droptarget) == drop6_mc )
                                • 14. Re: reset button and movie color change
                                  Jamesabth Level 1
                                  The second is correct - the first has too many brackets.

                                  Alternatively you could leave out the eval() statements (as they are not really needed) and type the instance names as strings:

                                  if(this._droptarget == "drop2_mc" || this._droptarget == "drop3_mc") //etc...

                                  but they both turn out the same.

                                  JAMES