3 Replies Latest reply on Nov 12, 2006 10:04 PM by kglad

    Moving movieclip with AS

      I'm quitre new with Flash and especially with AS. Allthought I have programmed another languages before. Well, I'm making simple animation, and I would like to move one symbol with action script. In my animation, ant runs to the left. Because this background must move to the right. Well, I have two problems. Firstly, how I can move backround symbol to the right? I tried something like:
      earth.x+=4; and earth._x+=4;
      after looking one example. However it won't work. Another problem is that earth's right side should appear from left when it is outside of stage's border so there don't appear white areas.
      Example picture:
      As you can see, background appears from opposite side and follows itself. how I can do that?

      Thank you very much! Help is appreciated
        • 1. Re: Moving movieclip with AS
          Hi Tume91
          To move a movieclip named "MyMovie", I would do the following;

          for (i=0; i<500; i++){
          MyMovie._x = i;

          As for the "earth" (background) image - You can either;
          1. Make it larger than the canvas and then move it as described above. OR
          2. Make multiple instances of the image and move both of them at the same time. (I think that this is what you have done.
          • 2. Re: Moving movieclip with AS
            Tume91 Level 1
            Thanks. Allthought your code moves my movieclip only once. Not like smoothly or something. But thanks anyways. This helped a lot.
            • 3. Re: Moving movieclip with AS
              kglad Adobe Community Professional & MVP
              for-loops (and while-loops) execute from beginning to end before anything is updated on-stage. so, they cannot be used for animation.

              use a setInterval() loop, onEnterFrame loop or a frame loop to continually execute your