3 Replies Latest reply: Dec 19, 2012 1:48 PM by kglad RSS

    How do I "Allow Smoothing" for XML loaded .jpg's ?

    nikolaig Community Member

      I have an image thumb scroller which loads a bunch of jpg's. They are being enlarged of rollover at 1.05.

      I see them pixelated at 1x1 scale as well as enlarged.

      I am prettey happy how Flash renders images with "Allow Smoothing" on.

      How would I do it for the xml loaded jpg's? Would it be in AS script on the main file or in the xml file?

       

      Here is how I load the images in AS3:

       

      function completeHandler_AppPopUps(e:Event):void{
                //trace("thumbnail complete "+e.target.loader.parent.parent.name)//tells us when the loading is complete
      
                //size image into scroller (need only if I will have images at different sizes)
                resizeMe(e.target.loader.parent, 60, 90, true, true, false);
      
                TweenMax.to(e.target.loader.parent.parent, .5, {alpha:.7});//makes all thumb images at alpha=.7 after they are fully loaded
                //Tweener.addTween(e.target.loader.parent.parent, { alpha:1, time: .5 } );//caurina version
      
                TweenMax.to(e.target.loader.parent.parent, .5, {colorMatrixFilter:{contrast:1.1, brightness: .7, saturation: .5}});//makes all thumb images at brightness:0.5 after they are fully loaded
      
      
      }
      
      

       

      I don't want to complicate things more than needed, but just in case it is needed here is the entire code section for building up the scroller:

       

      /////Parse XML
      //build scroller from xml
      function buildScroller(imageList:XMLList):void{
                trace("build Scroller");
      
                for (var item:uint = 0; item<imageList.length();item++) {
                          var thisOne:MovieClip = new MovieClip();
      
                          //outline
                           var blackBox:Sprite = new Sprite();
                          blackBox.graphics.beginFill(0xFFFFFF);
                          blackBox.graphics.drawRect(-1, -1, 62, 92);//-1,-1 places rectangle 1px left and up.62, 92 draws rectangle 1px wider on all sides of placed image dimenstions of 60x90
                          blackBox.alpha = thumbFadeOut;//setting Border Tweens
                          thisOne.addChild(blackBox);
                          thisOne.blackBox = blackBox;//setting Border Tweens
      
                            thisOne.x = thisOne.myx = (60 + padding) *item;//replaces the line above for scale tweenw roll over calculation. "myx" is a made up term which defines the position. 61 is the width of the thumb
                          thisOne.itemNum = item;
                          thisOne.title = imageList[item].attribute("title");
                          thisOne.link = imageList[item].attribute("url");
                          thisOne.src = imageList[item].attribute("src");
                          thisOne.alpha = 0;//makes all thumb images at alpha=0 before they are fully loaded
      
                          //Loading and Adding the Images
                          //image container
                          var thisThumb:MovieClip = new MovieClip();
                          //add image
                          var ldr:Loader = new Loader();
                          //var url:String = imageList[item].attribute("src");
                          var urlReq:URLRequest = new URLRequest(thisOne.src);
                          trace("loading thumbnail "+item+" into Scroller: " + thisOne.src);//url
                          ldr.load(urlReq);
                          //assign event listeners for Loader
                          ldr.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler_AppPopUps);//tells us when the loading is complete
                          ldr.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler_AppPopUps);//tells us if there are any typo errors when the loading is complete
                          thisThumb.addChild(ldr);
                          thisOne.addChild(thisThumb);
      
                          //create listeners for this thumb
                          thisOne.buttonMode = true;//makes boxes act as buttons
                          thisOne.addEventListener(MouseEvent.CLICK, clickScrollerItem_AppPopUps);//makes boxes act as buttons
                          thisOne.addEventListener(MouseEvent.MOUSE_OVER, overScrollerItem_AppPopUps);//traces the title when the mouse is over the bounding box in the Output Panel
                          thisOne.addEventListener(MouseEvent.MOUSE_OUT, outScrollerItem_AppPopUps);//traces the title when the mouse is out the bounding box in the Output Panel
      
      
      
                          //add item
                          scroller.addChild(thisOne);
                }
                scroller.addEventListener(Event.ENTER_FRAME, moveScrollerThumbs);//adding movement on mouse position
                trace("termination of build scroller");
      
      }
      
      
      
        • 1. Re: How do I "Allow Smoothing" for XML loaded .jpg's ?
          kglad CommunityMVP

          in your load complete listener enable the smoothing property to your loader's content (cast as a bitmap).

           

          function completeHandler_AppPopUps(e:Event):void{

          Bitmap(e.currentTarget.loader.content).smoothing=true;
                    //trace("thumbnail complete "+e.target.loader.parent.parent.name)//tells us when the loading is complete

                    //size image into scroller (need only if I will have images at different sizes)
                    resizeMe(e.target.loader.parent, 60, 90, true, true, false);

                    TweenMax.to(e.target.loader.parent.parent, .5, {alpha:.7});//makes all thumb images at alpha=.7 after they are fully loaded
                    //Tweener.addTween(e.target.loader.parent.parent, { alpha:1, time: .5 } );//caurina version

                    TweenMax.to(e.target.loader.parent.parent, .5, {colorMatrixFilter:{contrast:1.1, brightness: .7, saturation: .5}});//makes all thumb images at brightness:0.5 after they are fully loaded


          }

          • 2. Re: How do I "Allow Smoothing" for XML loaded .jpg's ?
            nikolaig Community Member

            Thank you for a straight forward answer, it works perfectly!

            • 3. Re: How do I "Allow Smoothing" for XML loaded .jpg's ?
              kglad CommunityMVP

              you're welcome.