11 Replies Latest reply on Mar 7, 2008 6:16 AM by pharaoh8

    Scale Dynamic Picture

    pharaoh8 Level 1
      I have a movie that calls up pictures through an xml file from my images directory. The image scales from 175% to 100%. It works just fine but I want it to appear as though it is scaling down from the center, not the top left registration point.

      My guess is that I need to find a way to either, 1) have the x & y values change with the scale to give the illusion of scaling from the center, or, 2) learn how to change the reg point of my blank_mc to the center with actionscript 2. In either case, I think the x & y values will have to change.

      I tried to do #1 above but I can't seem to get the x & y values to scale at an even pace. One arrives at 0 before the other.

      Have any suggestions?

      Thanks in advance.

      Code Below:
        • 1. Scale Dynamic Picture
          clbeech Level 3
          you could handle all of these functions a little easier by using the MovieClipLoader and Tween classes, as well as adjusting the 'picture' holding clip to adjust the image from the center. maybe something more like this:

          • 2. Re: Scale Dynamic Picture
            Level 7
            clbeech,

            Thanks for the response.

            I replaced my code with what you suggested (I hope that was the right thing
            to do) and I have a few errors. They are as follows:

            picture._x = [center here];
            picture._y = [center here];
            I assume that I put in the values of my picture as if it were centered on
            the stage, that would be 200 and 120 respectively.

            lstn.onProgress(clip, bl, bt) {
            Produces a syntax error. Are there values that I am supposed to input for
            "...(clip, bl, bt)..." ?

            lstn.onLoadInit(clip) {
            Same for above, do I replace clip with a value?

            mcl.loadClip(image[p], picture.holder);
            }
            Error: Unexpected '}' encountered

            Please forgive my ignorance but I am relatively new to advanced
            actionscripting, hence the reason for my original code.

            Again, thanks for the help, I hope furhter explanation is not too time
            consuming.

            dj pharaoh

            "clbeech" <webforumsuser@macromedia.com> wrote in message
            news:fqke3e$m8r$1@forums.macromedia.com...
            > you could handle all of these functions a little easier by using the
            > MovieClipLoader and Tween classes, as well as adjusting the 'picture'
            > holding
            > clip to adjust the image from the center. maybe something more like this:
            >
            >
            >
            > stop();
            > import mx.transitions.Tween;
            > import mx.transitions.easing.Strong;
            >
            > var p=0;
            > picture = this.createEmptyMovieClip('picture', 0);
            > holder = picture.createEmptyMovieClip('holder', 0);
            > picture._x = [center here];
            > picture._y = [center here];
            >
            > var mcl = new MovieClipLoader();
            > var lstn = new Object();
            > mcl.addListener(lstn);
            >
            > function loadPic() {
            > picture._alpha=0;
            > preloader.preload_bar._xscale=0;
            > preloader._visible=true;
            >
            > lstn.onProgress(clip, bl, bt) {
            > preloader.preload_bar._xscale = bl/bt*100;
            > }
            >
            > lstn.onLoadInit(clip) {
            > preloader._visible = false;
            > clip._x -= clip._width/2;
            > clip._y -= clip._height/2;
            > desctxt_mc.desc_txt.text = description[p];
            > desctxt_mc.date_txt.text = date[p];
            > pos_txt.text = p+' / '+ total;
            >
            > new Tween(clip, '_alpha', Strong.easeOut, 0, 100, 30, false);
            > new Tween(clip, '_xscale', Strong.easeOut, 175, 100, 30, false);
            > }
            > new Tween(clip, '_yscale', Strong.easeOut, 175, 100, 30, false);
            > p++;
            > }
            >
            > mcl.loadClip(image[p], picture.holder);
            > }
            >
            > advance_btn.onPress = function() {
            > loadPic();
            > }
            >


            • 3. Re: Scale Dynamic Picture
              clbeech Level 3
              Pharaoh - I had changed several things in the code you've quoted here, after re-reading it a couple of times lol!! :) so it looks like the code you have quoted above still is the 'original' version before I'd changed it. You'll find the 'edited' code above - although being a newsgroup subscriber, it may require you to log into adobe here to retrieve it i guess.

              It was fine to remove the old code, however, I always like to just comment out old code, when replacing it with something new until I get it working properly, or save an new version of the file, so that I can revert if necessary. Just a little tip :)

              I believe most of the errors are due to an 'extra' bracket, that was place incidentally, between the 'tweens' in the onLoadInit method.

              the 'centering' aspects you have correct. As to the other items, those are parameters that get passed into the method, and serve as variables within the method, and should not be replaced by values.

              Try the latest code version as above, and see what happens.
              • 4. Re: Scale Dynamic Picture
                pharaoh8 Level 1
                I will try this new code when I get a chance, maybe tomorrow. I will let you know how it goes.

                Rest assured that my original code is still tucked safely away.

                Thank you,

                Pharaoh
                • 5. Re: Scale Dynamic Picture
                  pharaoh8 Level 1
                  Good morning,

                  I am not able to find the new code you posted. I am logged in through the Adobe Forum, not the news reader. Could you please repost the edited code or tell me how to retrieve it?

                  Thanks,

                  Pharaoh
                  • 6. Re: Scale Dynamic Picture
                    clbeech Level 3
                    the code above was edited to reflect the changes.
                    • 7. Re: Scale Dynamic Picture
                      pharaoh8 Level 1
                      When I use the code from your first reply I get the same errors. Is this the code that you edited? The only other code of yours that I see is in my reply to your first one mentioned above...

                      This is what I used:

                      stop();
                      import mx.transitions.Tween;
                      import mx.transitions.easing.Strong;

                      var p=0;
                      picture = this.createEmptyMovieClip('picture', 0);
                      holder = picture.createEmptyMovieClip('holder', 0);
                      picture._x = [center here];
                      picture._y = [center here];

                      var mcl = new MovieClipLoader();
                      var lstn = new Object();
                      mcl.addListener(lstn);

                      function loadPic() {
                      picture._alpha=0;
                      preloader.preload_bar._xscale=0;
                      preloader._visible=true;

                      lstn.onProgress(clip, bl, bt) {
                      preloader.preload_bar._xscale = bl/bt*100;
                      }

                      lstn.onLoadInit(clip) {
                      preloader._visible = false;
                      clip._x -= clip._width/2;
                      clip._y -= clip._height/2;
                      desctxt_mc.desc_txt.text = description[p];
                      desctxt_mc.date_txt.text = date[p];
                      pos_txt.text = p+' / '+ total;

                      new Tween(picture, '_alpha', Strong.easeOut, 0, 100, 30, false);
                      new Tween(picture, '_xscale', Strong.easeOut, 175, 100, 30, false);
                      new Tween(picture, '_yscale', Strong.easeOut, 175, 100, 30, false);
                      p++;
                      }

                      mcl.loadClip(image[p], picture.holder);
                      }

                      advance_btn.onPress = function() {
                      loadPic();
                      }
                      • 8. Re: Scale Dynamic Picture
                        clbeech Level 3
                        LMAO!!!! oh man sorry pharaoh! I see now what I've missed! yes the last code you posted there is the correct script, however I have left out a critical section ...the two methods for the mcl handlers should read:

                        lstn.onProgress = function(clip, bl, bt) {
                        lstn.onLoadInit = function(clip) {

                        left out the 'function' while typing and still hadn't noticed until now lol!! put that in there and then let's see how it goes :)
                        • 9. Re: Scale Dynamic Picture
                          pharaoh8 Level 1
                          OK, I fixed the code as per your directions and I get NO errors. Yay!

                          But, there's always a but isn't there, now my picture doesn't show up at all. I have uploaded the entire project to my web page if you would like to take a look. You will find a link to the fla & swf files.

                          Please note that right now I am only working on the first picture, there are five, the other pictures that come up are still being controlled by the original code. Also, all the small white text and pictures are added dynamically via XML.

                          Here is the link: http://funkship.com/flash/ThisWeekDyn/test.html

                          I really appreciate all the help you have given me so far. I didn't realize that making the picture scale from the center would be so time consuming. I'll understand if this is becoming too big a deal.

                          Thanks,

                          Pharaoh
                          • 10. Re: Scale Dynamic Picture
                            clbeech Level 3
                            hey pharaoh - I've finally had a chance to review your file, and ... well ... kinda made some changes, well ok, rebuilt it ...LOL!!!! so you can find the file HERE take a chance to review it and then let's talk further :)
                            • 11. Re: Scale Dynamic Picture
                              pharaoh8 Level 1
                              WOW! Thanks for going the extra 10 miles. I was going to give up hope. I sent you a PM to see if I could get some light shed on the way the app works.

                              A million thanks for your efforts.

                              Pharaoh