2 Replies Latest reply on Oct 26, 2006 8:22 AM by Newsgroup_User

    how to center an image in a movie clip

    Venian Level 2
      Hi

      I have loaded an image at runtime into a movieclip (holder_mc) nested within another movieclip (image_mc) placed onto the stage. So I want to center the newly loaded image into the movieclip, because I load different images with diferrent sizes. So if the image is smaller than the movieclip I want it to be on the center of the movieclip.

      Could some one help me?

      Thnak you.
        • 1. Re: how to center an image in a movie clip
          kglad Adobe Community Professional & MVP
          AFTER loading is complete (ie, use preloader code or the onLoadInit() method of the moviecliploader class), you can use:

          • 2. Re: how to center an image in a movie clip
            Level 7
            kglad wrote:
            > AFTER loading is complete (ie, use preloader code or the onLoadInit() method of
            > the moviecliploader class), you can use:
            >
            >
            >
            > image_mc.holder_mc._x=.5*(image_mc._width-image_mc.holder_mc._width);
            > image_mc.holder_mc._y=.5*(image_mc._height-image_mc.holder_mc._height);
            >


            The original poster didn't mention if they were using MovieClipLoader or
            loadMovie(). I thought it worth mentioning that you need to use the
            MovieClipLoader class because the onLoadInit() event handler won't be
            available if you are using the loadMovie() method.

            I would also Math.round() your values so the image lines up on full
            pixels so there is no bitmap distortion.

            James


            --
            James O'Reilly — Consultant
            Adobe Certified Flash Expert
            http://www.jamesor.com
            Design • Code • Train