1 Reply Latest reply on Apr 29, 2006 11:04 PM by Newsgroup_User

    AS-generated MC with centered registration point?

    kevmedia.com Level 1
      Hi, thanks in advance for any guidance on this.

      You know how you can change the registration point of a MC in the properties dialog box? I'd like to do the same thing for an empty MC created via AS, so that I can position the thing in the center of the stage easily.

      If it were only one MC, I wouldn't bother asking this question. But I'm talking about loading in about 75 clips over the course of my project, depending on user activity. Since the clips are all different sizes, I don't want to calculate a custom left/top coordinate if there's any way to center the registration point instead via AS.

      (In the external swfs that I'm loading into my AS-created MC, I've already tried positioning the registration point of the MC on the stage inside that external swf. This had no effect on the empty MC I created with AS as a holder for my external swf. Hope that makes sense.)
        • 1. Re: AS-generated MC with centered registration point?
          Level 7

          "kevmedia.com" <webforumsuser@macromedia.com> wrote in message news:e31iqa$7mq$1@forums.macromedia.com...
          > Hi, thanks in advance for any guidance on this.
          >
          > You know how you can change the registration point of a MC in the properties
          > dialog box? I'd like to do the same thing for an empty MC created via AS, so
          > that I can position the thing in the center of the stage easily.

          The registration point isn't programmable but you can use a trick to get the job done. The idea is to use 2 movieclips. The first
          one, mc1, gets visibility settings and rotation etc, while the 2nd one inside of mc1 gets the image loaded into it.

          This code creates two clips, loads the jpeg, waits until the header part of the jpeg comes in to get the width and height values,
          then positions the clip and turns on visibility.
          It is a demo to rotate an external jpeg around it's center point.
          tralfaz

          this.createEmptyMovieClip("mc1",1);
          mc1.createEmptyMovieClip("mc2",2);
          mc1._visible = false; // don't want to see the repositioning happen
          loadMovie('image1.jpg', mc1.mc2);
          id = setInterval(positionClip, 400);

          function positionClip()
          {
          // wait until the jpeg header comes in (the first 19 bytes)
          if(!mc1.mc2._width) // if zero, just quit for now
          return;

          clearInterval(id); // don't need this function anymore
          mc1._x = 400; // position the base clip
          mc1._y = 300;

          // move the 2nd clip mc2 relative to the first clip mc1
          // this puts the center of the loaded jpeg in mc2 on the top
          // left corner of mc1 giving you a way to rotate about the
          // center point of mc2

          mc1.mc2._x = mc1.mc2._x - (mc1.mc2._width / 2);
          mc1.mc2._y = mc1.mc2._y - (mc1.mc2._height / 2);
          mc1._visible = true; // visible now
          id = setInterval(spin, 12); // start rotation
          }


          spin = function()
          {
          mc1._rotation += 3; // rotate the base clip
          updateAfterEvent(); // make it smoother looking
          }