4 Replies Latest reply on Aug 8, 2011 1:26 PM by kglad

    Dynamically loaded .jpg are pixelated

    pfess111

      I realize this topic has been discussed ad nauseum, but I've tried finding and implementing a solution to no avail.  For some reason only some of the .jpgs on my flash site that are being loaded dynamically are loading pixelated. I've tried to look up solutions to this, but I'm not exactly sure where a quality=best or smoothing=true script should be placed. And I'm equally as puzzled as to why only some of my .jpgs are loading pixelated? This is very frustrating, this is the code I'm using to load my images, please help:

       

       

      On the timeline where the movieclip is located I have the following code:

      loadMovie("Wave.jpg", _root.image_box_9);

       


      On the movieclip itself I have this code in order to create a fade in:

       


      onClipEvent(load){
      this._alpha = 0;
      speed = 10; // change this to change fade speed
      }

      onClipEvent(enterFrame){
      loaded = this.getBytesLoaded()/this.getBytesTotal();
      if(loaded == 1){
      this._alpha += speed;
      } else {
      this._alpha = 0;
      }
      if(this._alpha >= 100){
      this._alpha = 100;
      }
      }


      Could someone please tell me how to smooth this image? I would really appreciate it.

        • 1. Re: Dynamically loaded .jpg are pixelated
          kglad Adobe Community Professional & MVP

          in general, it's poor coding practice to attach code to objects.  in your specific situation, it's really bad coding because that loop continues to execute for as long as your movieclip exists.

           

          you should attach code to a frame and terminate that loop when it's no longer needed and you can use forceSmoothing to enable anti-aliasing.  remove the code attached to whatever object you showed and replace your code with:

           


          _root.image_box_9.loadMovie("Wave.jpg");

          _root.image_box_9._alpha=0;
          _root.image_box_9.speed=10;

          clearInterval(preloadI);
          preloadI=setInterval(preloadF,70);

          function preloadF():Void{
          if(_root.image_box_9.getBytesLoaded()>=_root.image_box_9.getBytesTotal() && _root.image_box_9.getBytesLoaded>100){
          _root.image_box_9._alpha+=_root.image_box_9.speed;
          _root.image_box_9.forceSmoothing=true;
          if(_root.image_box_9._alpha>=100){
          clearInterval(preloadI);
          }
          }
          }
          • 2. Re: Dynamically loaded .jpg are pixelated
            pfess111 Level 1

            Kglad,

             

             

            Thanks for your response.  I replaced the "loadMovie("Wave.jpg", _root.image_box_9) "  that was on the frame with your suggested code, and deleted the fade in code that was on the movieclip itself.  However the image won't load at all using your code.  Am I missing something here?

            • 3. Re: Dynamically loaded .jpg are pixelated
              pfess111 Level 1

              kglad,

               

              Ok I've got your code working now, but the image is still pixelated.  The second line where you had the alpha set to 0 I changed to 100, so it isn't fading in like I want it to.  Do you have another suggestion for the pixelation and how to fade in my image using your code?

               

               

              I appreciate your patience. 

              • 4. Re: Dynamically loaded .jpg are pixelated
                kglad Adobe Community Professional & MVP

                you should be using the code i suggested.  if you changed anything copy and paste the code you're using.

                1 person found this helpful