9 Replies Latest reply on Dec 1, 2007 2:53 PM by Greg Dove

    How to Center loadMovie Registration Point

    if else
      Hello Flash Tech's,
      I really having trouble figuring this one out.
      I'm trying to use Zoom transition for my photo Gallery which I'm using loadMovie "jpg" from Xml file.
      Now the problem is here.
      The Registration Point is set to the top upper left corner and I would like it to be in the center of my loadMovie.
      The Zoom transition only zoom from left corner and need to be center equal sides.
      How do I do this. My image size is "width 400px height 240px
      Thanks....
        • 1. Re: How to Center loadMovie Registration Point
          Greg Dove Level 4
          The way I would do it is to use MovieClipLoader and load into an empty Child Clip of an empty image Holder.

          Assign a listener to the MovieClipLoader and in its onLoadInit handler, offset its _x and _y properties by -width/2 and -height/2.

          In this case you can centre clips of differing sizes.

          You position the parent/image Holder clip. The loaded image is centered inside it.
          • 2. Re: How to Center loadMovie Registration Point
            if else Level 1
            Thanks GWD,
            but how would I write this in codes?
            • 3. How to Center loadMovie Registration Point
              Greg Dove Level 4
              I just typed this quickly. Didn't test it... but something like this.
              • 4. How to Center loadMovie Registration Point
                if else Level 1
                This is how I'm loading the image in
                loadMovie(Pic1, _root.artpics_mc.pic1_mc);

                Pic1 is the jpg var..

                Now I see your code and did this

                //example
                this.createEmptyMovieClip("imageHolder",this.getNextHighestDepth());

                //position imageHolder
                imageHolder._x=Stage.width/2
                imageHolder._y=Stage.height/2;
                var innerJpegTarget= imageHolder.createEmptyMovieClip("jpgHolder",imageHolder.getNextHighestDepth());

                var mcl:MovieClipLoader = new MovieClipLoader();

                var mclListener:Object=new Object();
                mclListener.onLoadInit=function(targ){
                //centre it
                targ._x=-targ._width/2;
                targ._y=-targ._height/2;
                }

                mcl.addListener(mclListener);

                mcl.loadClip("Pic1",innerJpegTarget);


                Does that above look correct?

                Now when I appear the Zoom Transition.

                import mx.transitions.*;
                import mx.transitions.easing.*;


                function tweenBall() {
                easeType = mx.transitions.easing.Regular.easeOut;
                var begin = 300;
                var end = 100;
                var time = 3;
                var position = startPoint=5;

                var mc = _root.artpics_mc.pic1_mc;
                Pic1 = new mx.transitions.Tween(mc, "_yscale", easeType, begin, end, time, true);
                Pic1 = new mx.transitions.Tween(mc, "_xscale", easeType, begin, end, time, true);
                }

                tweenBall();

                It is still zooming in the top left corner. What am i'm doing wrong?
                Everything is in the second frame together.
                I'm confused. Is it a easier way of doing this?


                I seen this code in another forum:
                var container:MovieClip = _root.createEmptyMovieClip ("container", 1);
                container._x = 200;
                container._y = 200;
                var holder:MovieClip = _root.container.createEmptyMovieClip ("holder", 1);
                holder.loadMovie ("movie.swf");
                container.onEnterFrame = function ()
                {
                holder._x = (-this._width / 2);
                holder._y = (-this._height / 2);
                this._rotation += 10;
                };
                • 5. Re: How to Center loadMovie Registration Point
                  Greg Dove Level 4
                  Well I would normally tween the parent clip's scale properties , which would be imageHolder in my example, after loading into an inner target.

                  You're still tweening _root.artpics_mc.pic1_mc.

                  You could perhaps use _root.artpics_mc.pic1_mc as your image holder and create the jpg holder clip inside it.

                  Are you still using your old loadMovie code as well? This approach was just an example that you could explore. Also you said Pic1 was you jpeg variable. I assume you mean its a variable that contains the path to load your image from.In which case using "pic1" in the loadClip("Pic1",innerJpegTarget) will result in a silent runtime error because "Pic1" is probably not the name of your jpeg. use Pic1 like you did in loadMovie.
                  • 6. How to Center loadMovie Registration Point
                    if else Level 1
                    Thanks GWD!

                    It worked. Now I just got to figure out how to mask edges of the created Movie Clip loader.
                    I have a physical mask but with the createmovieclip function the movieclip shows through the mask I was using for the loadMovie. So I think I need to mask it in actionscript to hide edges from the zoom transition.... Do you know how to apply this?
                    • 7. Re: How to Center loadMovie Registration Point
                      Greg Dove Level 4
                      You could (again with my example) try the following approach

                      Create a clip the shape, size and location of your mask on a normal layer. Give it a name in the properties panel. E.g. maskClip
                      then put the line :
                      imageHolder.setMask(maskClip);

                      after the imageHolder clip is created.

                      try that. I normally create my masks using actionscript as well... but I'm pretty sure it should work with an existing clip you put on the stage. Its the easiest way to describe how to do it .
                      • 8. How to Center loadMovie Registration Point
                        if else Level 1
                        Thanks Again GWD!

                        I learned something new today. Now I can finish my project.
                        You the man.........