5 Replies Latest reply on Aug 2, 2008 12:11 PM by kglad

    Actionscript 2

      Hello everyone,

      Here I am again with a different problem.

      I am creating a small game where the user will have to move objects on the canvas. If the object goes to the correct location, then the object will stay there, if the object is not in the correct location then this will go back to the location it started from. I have been reading articles on top of articles but I do not seem to be able to find any reference to how to solve this problem.

      Is there anyone who would be so kind to help me?

      Thank you
        • 1. Re: Actionscript 2
          Level 7
          You didn't really state what the problem is. You can check to see if an
          object is in a given spot by checking it's location, or by doing a hit test
          against another clip. You can use a tweening engine (I like Tweener) to move
          the object back to its starting point.

          So - onPress do a startDrag. onRelease check the position. If it's not where
          you want move it back to start using a tween, otherwise it's where you
          want - delete the onPress so it can't be moved again.

          Dave -
          Head Developer
          Adobe Community Expert

          • 2. Re: Actionscript 2
            Brutium Level 1
            Hello Dave,

            Thank you for your reply. The followinf is the code I wrote in order to see if the object I am moving goes to the right place or not. My proble is that I cannot figure out how to have pcellmemb_mc go back to the original (starting) position and also to have the second message (try again) appear in the Dynamic Text box (answer1)

            any suggestion?

            Thank you


            this.startDrag (true);

            this.stopDrag ();
            answer1.text = "WELL DONE!";

            this.stopDrag ();
            if(this.hitTest <>(_root.memb_mc));
            answer1.text = "Try Again";
            • 3. Re: Actionscript 2
              kglad Adobe Community Professional & MVP

              • 4. Actionscript 2
                Brutium Level 1
                Thank you, thank you, thank you KGLAD!

                That worked like a charm. That was exactly what I have been strugling with. Thank you!

                If I may, can I ask another question?

                What can I do to restart the movie at anytime from the beginning, if I need to?
                • 5. Re: Actionscript 2
                  kglad Adobe Community Professional & MVP
                  you're welcome.

                  there's no magic restart function short of reloading your application: