5 Replies Latest reply on Jul 6, 2006 4:00 PM by Rothrock

    resize dynamically loaded images

    Level 7
      Hi All,

      I have a movie in which images are imported dynamically from a folder on
      my pc to my movie (not using a webserver). I would like to resize them
      when loaded but I just can't get it to work.

      I have tried:
      container._height=125;
      container._width=125;
      // they are square images

      I can get a rescale using container_xscale=75; etc., but not all the
      images are the same size, although they are all square so even a rescale
      will make the images irregular sizes.
      I tried the code in different places and with an onLoadInit listener to
      make sure the image was loaded, no joy!

      Any help really appreciated,

      Jeff C
        • 1. Re: resize dynamically loaded images
          kglad Adobe Community Professional & MVP
          show your code that used the onLoadInit() handler.
          • 2. Re: resize dynamically loaded images
            Level 7
            kglad wrote:

            >show your code that used the onLoadInit() handler.
            >
            >
            Thanks kglad,

            Sorry, it wasn't the onLoadInit(), it was the onLoadComplete() handler.

            I got it working, kind of, when included in an onEnterFrame event. It
            resizes all the pics to the same size... perfect. The problem now, is
            that when I roll over the image, it increases the image size only for an
            instant and returns to the original size. I want to roll over the image
            and it remains large until rollout.
            The code is:


            stop();
            debug.vScrollPolicy ="on"; //debug is a textfield that shows when an
            image is loaded
            myMCL = new MovieClipLoader(); //define MovieClipLoader
            myListener = new Object(); //define listener

            //notify when mc is loaded
            myListener.onLoadComplete = function(targetMC){
            targetMC.onEnterFrame = function(){ //resize the images to equal size
            targetMC._width=50;
            targetMC._height=50;
            }
            debug.text += "LOADING OF " + targetMC // update the debug field
            + " COMPLETE" + newline;

            targetMC.onRollOver = function() { // increase the size of image
            on rollover
            debug.text += newline // add debug line to indicate the
            rollover was activated
            + "targetMC = " + targetMC._name;
            targetMC._height=75;
            targetMC._width=75;

            }
            }

            // create mc and begin the loading process
            function initClips(){
            for (i=1; i<=4; i++){
            this.attachMovie("img", "img" + i, i);
            this["img"+i]._x = i*110;

            myMCL.loadClip("pic" + i + ".jpg" ,
            this["img"+i]); //code wrapped

            }
            }

            // to loop
            myMCL.addListener(myListener);
            initClips();

            Any assistance really appreciated,

            Jeff C
            • 3. Re: resize dynamically loaded images
              Level 7
              Instead of using onLoadComplete, do as kglad suggested and use onLoadInit.
              Size the clip in there, and you won't need the enterFrame.

              --
              Dave -
              Adobe Community Expert
              www.blurredistinction.com
              http://www.adobe.com/communities/experts/


              • 4. Re: resize dynamically loaded images
                Level 7
                DMennenoh **AdobeCommunityExpert** wrote:

                >Instead of using onLoadComplete, do as kglad suggested and use onLoadInit.
                >Size the clip in there, and you won't need the enterFrame.
                >
                >
                >
                Perfect!! I owe you... along with all the newsgroup helpers who've given
                me advice! I'm new to Flash, so I'm piecing together different codes
                and learning from that.

                Now I get the difference, onLoadComplete runs when the image is loaded
                but it's MC's methods and properties aren't accessible because the
                content is already initialized - too late to adjust size. The onLoadInit
                runs when the image is loaded but before it's initialized - still time
                to change properties.

                Thanks for the help. A pointer in the right direction is a lesson in itself!

                Jeff C
                • 5. Re: resize dynamically loaded images
                  Rothrock Level 5
                  And the BEST pointer here is to always list the little relevant bits of your code. :)