5 Replies Latest reply on Jun 14, 2009 1:12 PM by kglad

    More Flash 5 Help!

    ZettaGeek

      Howdy All!

       

      The awesome folks over at Kglad.com helped me make an object tween (without easing) to the location of a mouse click. See here:

      http://forums.adobe.com/message/1920716#1920716

       

      I need to take the script a step further though, I need it to stop an imported movie clip when it reaches its destination. How do I do this?

       

      Thanks for your help!

        • 1. Re: More Flash 5 Help!
          kglad Adobe Community Professional & MVP

          is that a loaded movieclip that you want to stop?  if so, what method are you using to load that swf?   ie, are you using something like loadMovie("yourswf.swf",yourtargetMC) ?  show the code you use

           

          do you mean you want to stop the timeline of the loaded clip from advancing (or playing)?

          • 2. Re: More Flash 5 Help!
            ZettaGeek Level 1

            Howdy,

             

            Basically, I believe I'm putting the IF command to stop the movie in the wrong place.. But I'm not sure since it isn't working.

             

            I'm pasting the code both here and on Pastebin:

             

            -----------------------------------------------------------------------------------

            Code:

             

            onClipEvent (data) {
                startX2 = startX;
                startY2 = startY;
                endX2 = endX;
                endY2 = endY;
                endfinal1 = startX2+startY2;
                endfinal2 = endX2+endY2;
                if (endfinal1 == endfinal2) {
                    _root.char.stop();
                }
            }
            onClipEvent (load) {
                _x = this._x;
                _y = this._y;
                speed = 5;
                // pixels/loop
            }
            onClipEvent (mouseDown) {
                _root.char.play();
                counter = 0;
                startX = _x;
                startY = _y;
                endX = _root._xmouse;
                endY = _root._ymouse;
                loops = Math.round(_parent.distF(startX-endX, startY-endY)/speed);
            }
            onClipEvent (enterFrame) {
                counter++;
                if (counter<=loops) {
                    _x += (endX-startX)/loops;
                    _y += (endY-startY)/loops;
                }
            }

             

             

            -----------------------------------------------------------------------------------

             

            Code Pastebin:

             

            http://pastebin.com/f5b07954a

             

            -----------------------------------------------------------------------------------

            The code near the top was what I was using for trying to detect its end location.... (I know, syntax errors. :-O)

             

             

            Thanks for your help

            • 3. Re: More Flash 5 Help!
              kglad Adobe Community Professional & MVP

              and i'm not so sure you should be using a data event.

               

              if you're trying to check if your object has completed its tween use:

               

              /*

              onClipEvent (data) {

                  startX2 = startX;

                  startY2 = startY;

                  endX2 = endX;

                  endY2 = endY;

                  endfinal1 = startX2+startY2;

                  endfinal2 = endX2+endY2;

                  if (endfinal1 == endfinal2) {

                      _root.char.stop();

                  }

              }

              */
              onClipEvent (load) {
                  _x = this._x;
                  _y = this._y;
                  speed = 5;
                  // pixels/loop
              }
              onClipEvent (mouseDown) {
                  _root.char.play();
                  counter = 0;
                  startX = _x;
                  startY = _y;
                  endX = _root._xmouse;
                  endY = _root._ymouse;
                  loops = Math.round(_parent.distF(startX-endX, startY-endY)/speed);
              }
              onClipEvent (enterFrame) {
                  counter++;
                  if (counter<=loops) {
                      _x += (endX-startX)/loops;
                      _y += (endY-startY)/loops;
                  } else {

              _root.char.stop();

              }
              }

               

               

              -------------------------------------------------------------------------------- ---

               

              Code Pastebin:

               

              http://pastebin.com/f5b07954a

               

              -------------------------------------------------------------------------------- ---

              The code near the top was what I was using for trying to detect its end location.... (I know, syntax errors. :-O)

               

               

              Thanks for your help

              • 4. Re: More Flash 5 Help!
                ZettaGeek Level 1

                This code works great! THANK YOU KGLAD.COM!

                • 5. Re: More Flash 5 Help!
                  kglad Adobe Community Professional & MVP

                  you're welcome.