5 Replies Latest reply on May 12, 2009 8:14 AM by kglad

    Smooth dynamically loaded jpgs in AS2

    Walter Elias Level 2

      Simple problem, but the answer baffles me. I've spent half a day searching all the solutions to this question, but nothing works for me.

       

      Here's the problem:

       

      I'm setting up an online picture gallery. I'm trying to make it easy for the client to insert specific images, dynamically loaded, have them appear at 63 percent. If the user clicks on one, it enlarges to 100 percent. Trouble is, when the image is at 63 percent, it is not smooth and looks terrible,

       

      All the BitmapData class solutions posted online work for individual images. But I can't figure out how to automate the process in a for loop. At this point I'm not even worrying about the enlarging. I just want the images to load at 63 percent and look smooth.

       

      Below is the code for two images. Later I'll increase this to 25.

       

      On the stage are two colored rectangle movie clips: toon1 and toon2. I want the dynamically loaded jpegs to load inside them. The client will manually edit the last lines whenever she feels like it, to choose which images to load.

       

      What I need is an elegant AS2 solution in which any dynamically loaded jpeg will be smoothed.

       

      ------------------------------------

      for (i=1; i<=2; i++) {
          this["toon"+i].createEmptyMovieClip("cartoon",this.getNextHighestDepth());
          this["toon"+i].cartoon._xscale = this["toon"+i].cartoon._yscale=63;
          this["toon"+i].cartoon._x = 8;
          this["toon"+i].cartoon._y = 9;
      }

       

      toon1.cartoon.loadMovie("0025.jpg");
      toon2.cartoon.loadMovie("0054.jpg");

      ------------------------------------

       

      Please don't suggest xml or AS3 solutions. Those are incomprehensible to me. If anyone has an elegant AS2 solution I will be immensely grateful.

        • 1. Re: Smooth dynamically loaded jpgs in AS2
          kglad Adobe Community Professional & MVP

          after loading is complete (ie, use preloader code or the moviecliploader class'es onLoadInit) enable the forceSmoothing property of the target movieclip(s).

          • 2. Re: Smooth dynamically loaded jpgs in AS2
            Walter Elias Level 2

            Sorry, I don't completely understand. I haven't used ActionScript in a long time, so I've forgotten quite a bit. I have tried to implement the onLoadInit into my (for) loop, and it doesn't work at all. Can you please give me an example of how I can adapt a script such as this one (below) to my for loop, and also include the forceSmoothing property? When I try it myself, nothing works.

             

            var listenerObj:Object = new Object();
            listenerObj.onLoadInit = function (target_mc:MovieClip):Void {
                target_mc.forceSmoothing=true;
            }

            var movieClipLoader:MovieClipLoader = new MovieClipLoader();
            movieClipLoader.addListener(listenerObj);
            movieClipLoader.loadClip(url, movieClip);

            • 3. Re: Smooth dynamically loaded jpgs in AS2
              kglad Adobe Community Professional & MVP
              var lo:Object=new Object();
              lo.onLoadInit=function(target:MovieClip){
              target.forceSmoothing=true;
              }
              var mcl:MovieClipLoader=new MovieClipLoader();
              mcl.addListener(lo);

               

              ------------------------------------

              for (i=1; i<=2; i++) {
                  this["toon"+i].createEmptyMovieClip("cartoon",this.getNextHighestDepth());
                  this["toon"+i].cartoon._xscale = this["toon"+i].cartoon._yscale=63;
                  this["toon"+i].cartoon._x = 8;
                  this["toon"+i].cartoon._y = 9;
              }

              mcl.loadClip("0025.jpg",toon1);

              mcl.loadClip("0054.jpg",toon2);

               

              //toon1.cartoon.loadMovie("0025.jpg");
              //toon2.cartoon.loadMovie("0054.jpg");

              ------------------------------------

               

               

              • 4. Re: Smooth dynamically loaded jpgs in AS2
                Walter Elias Level 2

                Thank you very much for your help. It works fine, AND I now understand the concept and how to implement it. I appreciate your patience.

                • 5. Re: Smooth dynamically loaded jpgs in AS2
                  kglad Adobe Community Professional & MVP

                  you're welcome.