6 Replies Latest reply on Apr 19, 2006 5:34 PM by Phomari7

    _rotate not centering

    Phomari7 Level 1
      I have created a movieclip in AS. It is centered on the stage and its parent mc. When I rotate it, it is clear that it is rotating around some origin point not in the center of my stage.

      How can I rectify this? How do I know what point a mc will rotate around?

      Many thanks for responses. -jheske
        • 1. Re: _rotate not centering
          DuhChamp
          I'm not sure, but it may have to do with your movieClips registration point. Where is it located?
          • 2. Re: _rotate not centering
            shyaway Level 1
            all dynamic created mc have registration point at (0,0) top/left
            if you want the registration point to be else where, it has to be created before run-time.
            • 3. Re: _rotate not centering
              Phomari7 Level 1
              I guess I'll have to create a container at design-time to hold all the AS-created mc's.

              Thanks very much for the responses. Not sure I ever would have found that one!

              -Jill
              • 4. Re: _rotate not centering
                Level 7
                "Phomari7" <webforumsuser@macromedia.com> wrote in message news:e262ub$hn4$1@forums.macromedia.com...
                >I guess I'll have to create a container at design-time to hold all the AS-created mc's.
                >
                > Thanks very much for the responses. Not sure I ever would have found that one!
                >
                > -Jill

                You can do it if you make two clips instead of one and position the center of the 2nd clip on the top left corner of the 1st clip,
                then rotate the 1st clip.
                The double clip trick is a common thing used to be able to manipulate the alpha and other properties while the 2nd clip is loading
                an image.
                The re-positioning of the 2nd clip can't take place until the loading is finished though, so there is a preloader added for that.
                Here is a working example of loading a picture into a clip and doing center rotation..
                tralfaz

                this.createEmptyMovieClip("mc1", 10);
                this.mc1.createEmptyMovieClip("mc2", 11);

                mc1._x = Stage.width / 2;
                mc1._y = Stage.height / 2;
                mc1._visible = false; // hide it until it's loaded and positioned
                mc1.mc2.loadMovie("image1.jpg"); // start loading into 2nd clip
                id1 = setInterval(preloader, 100); // start the preloader

                //*****************************************************
                function preloader()
                {
                var gbt = _root.mc1.mc2.getBytesTotal();
                var gbl = _root.mc1.mc2.getBytesLoaded();

                if( (gbt > 12) && (gbl == gbl) ) // empty clip is 12 bytes
                {
                clearInterval(id1); // fully loaded, end the preloader
                mc1._visible = true; // make the holder clip visible now
                // mc1's point of rotation is top left. To make mc2 rotate
                // around it's center, move mc2's center point to the top
                // left corner of mc1, then rotate mc1
                _root.mc1.mc2._x = -_root.mc1.mc2._width / 2;
                _root.mc1.mc2._y = -_root.mc1.mc2._height / 2;

                _level0.onEnterFrame = function()
                {
                mc1._rotation++; // rotate the holder clip, not the image clip



                //*****************************************************




                • 5. Re: _rotate not centering
                  Level 7
                  I don't know why part of the code was cut off at the bottom..


                  this.createEmptyMovieClip("mc1", 10);
                  this.mc1.createEmptyMovieClip("mc2", 11);

                  mc1._x = Stage.width / 2;
                  mc1._y = Stage.height / 2;
                  mc1._visible = false; // hide it until it's loaded and positioned
                  mc1.mc2.loadMovie("image1.jpg"); // start loading into 2nd clip
                  id1 = setInterval(preloader, 100); // start the preloader

                  //*****************************************************
                  function preloader()
                  {
                  var gbt = _root.mc1.mc2.getBytesTotal();
                  var gbl = _root.mc1.mc2.getBytesLoaded();

                  if( (gbt > 12) && (gbl == gbl) ) // empty clip is 12 bytes
                  {
                  clearInterval(id1); // fully loaded, end the preloader
                  mc1._visible = true; // make the holder clip visible now
                  // mc1's point of rotation is top left. To make mc2 rotate
                  // around it's center, move mc2's center point to the top
                  // left corner of mc1, then rotate mc1
                  _root.mc1.mc2._x = -_root.mc1.mc2._width / 2;
                  _root.mc1.mc2._y = -_root.mc1.mc2._height / 2;

                  _level0.onEnterFrame = function()
                  {
                  mc1._rotation++; // rotate the holder clip, not the image clip
                  }
                  }
                  }
                  //*****************************************************


                  • 6. Re: _rotate not centering
                    Phomari7 Level 1
                    Thanks very much for the code snippet. I have implemented a variation on that solution, and I think it will work.

                    -jheske