2 Replies Latest reply on Apr 28, 2006 9:19 AM by Newsgroup_User

    How to assign movie clip's center point?

    programmerG
      My dilemma: I) I create an empty movie clip in flash via actionscript. 2) I use the "lineto" command multiple times to create a polygon (as part of the movie clip) and then I fill it. 3) Everything works great, the drawn movie clip is on the screen. 4) I write code to rotate the movie clip and the center point isn't the middle of the movie clip, it's the origin on the screen. The movie clip literally rotates and moves off the screen in a large circle.

      How do I set the movie clip's center point in actionscript so that it will be in the center of the movie clip itself, thus allowing it to rotate in place?
        • 1. Re: How to assign movie clip's center point?
          shyaway Level 1
          this topic has been cover multiple times. have you tried the forum search?

          when creating an mc with script, the registration point is always at top/left (zero,zero).
          a quick get-around to resolve this is to create an inner mc that is the actual circle you want. then reposition it so that the center of the circle is possition at (0,0) of its parent.
          by this point, you can rotate the parent and it will look like the origin (registration point) is in the center and not top/left.

          the existing threads probably cover a lot more details, and the correct search words, "registration point"
          • 2. Re: How to assign movie clip's center point?
            Level 7
            You could create an inner movie clip and draw to it. Once you've finished
            drawing, center it in its parent.

            i.e.

            var mc_outer = this.createEmptyMovieClip("mc_outer",
            this.getNextHighestDepth());
            var mc_inner = mc_outer.createEmptyMovieClip("mc_inner",
            mc_outer.getNextHighestDepth());

            // draw a square in the inner mc
            mc_inner.beginFill(0xFF0000);
            mc_inner.moveTo(0, 0);
            mc_inner.lineTo(100, 0);
            mc_inner.lineTo(100, 100);
            mc_inner.lineTo(0, 100);
            mc_inner.lineTo(0, 0);
            mc_inner.endFill();


            mc_inner._x = 0 - (mc_inner._width/2);
            mc_inner._y = 0 - (mc_inner._height/2);




            "programmerG" <webforumsuser@macromedia.com> wrote in message
            news:e2tei9$ie$1@forums.macromedia.com...
            > My dilemma: I) I create an empty movie clip in flash via actionscript.
            2) I
            > use the "lineto" command multiple times to create a polygon (as part of
            the
            > movie clip) and then I fill it. 3) Everything works great, the drawn
            movie
            > clip is on the screen. 4) I write code to rotate the movie clip and the
            center
            > point isn't the middle of the movie clip, it's the origin on the screen.
            The
            > movie clip literally rotates and moves off the screen in a large circle.
            >
            > How do I set the movie clip's center point in actionscript so that it
            will be
            > in the center of the movie clip itself, thus allowing it to rotate in
            place?
            >