4 Replies Latest reply on Nov 20, 2008 10:50 AM by Ger75

    Stopping movie clip

    Ger75
      Here is the problem. I am an actionscript newbie. I have a movie clip moving across the stage on the main timeline and want to stop it when it reaches a certain x value. I can't seem to get it to stop and stay still at position -700. Any help would be great!! Below is the code
        • 1. Re: Stopping movie clip
          Ned Murphy Adobe Community Professional & MVP
          I'm not sure of the scenario you're working with, but you want to have the advancement inside the conditional, otherwise, it will definitely not stay still. If your scenario allows for it, I'd get 'this' out of that frame just after setting the _X = -700.

          onClipEvent (enterFrame) {
          if (this._x < -700) {
          this._x += 1.5;
          else {
          this._x = -700;
          }
          }
          • 2. Re: Stopping movie clip
            Ger75 Level 1
            Thanks. I tried the script below but still can't get it to work. I have the script on a movie clip and the movie clip resides on the main timeline. The movie clip is pretty long and extends off of the stage to the left. It moves left to right. I want it to stop when it gets to a certain x value (a value of -700). It moves but doesn't stop with this script. Btw, thanks alot. Can you recommend an actionscript resource for beginners?

            • 3. Re: Stopping movie clip
              Ned Murphy Adobe Community Professional & MVP
              Your using == when you shouldn't. = is to assign something, == is to compare something.

              You're testing if x > -700 and telling it to go even more greater (+1.5), so it will never get there, especially if it already is > -700. Where is the object to start with relative to -700 and which direction is the object supposed to be moving? For what I could interpet of your original code, if it is advancing positive, it has to be more negative than -700 to ever get there. Try to think this thru and build the code logically from that thought process... and use the right = vs ==.
              • 4. Re: Stopping movie clip
                Ger75 Level 1
                This makes sense. Thank you!