1 Reply Latest reply on Jul 27, 2011 2:39 AM by relaxatraja

    Poor JPEG quality when loaded externally in flash via .xml

    jaimewolf24

      Hoping someone can help me out here, I know very little about flash and hence I've been trying to find a solution to this problem for days but to no avail.

       

      Basically, my problem is that I have a movie that loads images from an external source based on paths contained within an .xml. As far as I can see, there is no restriction to the size of the loaded image, which are are JPEGs, hence flash will not have these images resized. The images look fine when loaded in Photoshop or viewed separately, but the quality is just awful when loaded within the movie.

       

      I've tried the usual hints like increasing JPEG quality in Publish Settings, but understand that since these images are not imporated into Flash CS5 before compiling, but are instead loaded when the .swf is run, these settings would not have any effect.

       

      Does anyone happen to know if I have to add a line of code to Actionscript to resolve this problem? I'll add the code below if it is of any help.

      stop();

      var my_x:Number;
      var my_y:Number;
      var my_images:XMLList;
      var my_total:Number;

      var myXMLLoader:URLLoader = new URLLoader();
      myXMLLoader.load(new URLRequest("XML/artifactsXML.xml"));
      myXMLLoader.addEventListener(Event.COMPLETE, processXML);

      function processXML (e:Event):void{
          var myXML:XML = new XML(e.target.data);
         
          my_images = myXML.IMAGE;
          my_total = my_images.length();
          var preloader = new preloader_mc();
          preloader.x = 100;
          preloader.y = 145;
         
          callValues();
          cardNames_mc.content_mc.addEventListener(MouseEvent.CLICK, callImages);
         
          var initialLoader:Loader = new Loader();
          var initialURL = my_images[0].@PATH;
          initialLoader.load(new URLRequest(initialURL));
          picHolder_mc.addChild(initialLoader);
         
          }
         
      function callImages(e:MouseEvent){
          //trace(e.target.parent.number);
          var imageLoader:Loader = new Loader();
          var imageURL = my_images[e.target.parent.number].@PATH;
          imageLoader.load(new URLRequest(imageURL));
          picHolder_mc.addChild(imageLoader);
          }

      function callValues():void{
          var temp:Number = 10;
          for (var i:Number = 0; i < my_total; i++){
         
              var card:MovieClip = new card_mc();
              card.y = temp;
              card.x = 20;
              card.cardLabel_txt.text = my_images[i].@NAME.toString();
              cardNames_mc.content_mc.addChild(card);
              card.cardLabel_txt.parent.number = i;
             
              //var value_name = my_images[i].@NAME;
              /*var value_loader = new Loader();
              value_loader.load(new URLRequest(value_name));
              value_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, valueLoaded);*/
              temp+=20;
              }
          }
         
      function valueLoaded(e:Event):void{
          var my_image:Loader = Loader(e.target.loader);
          cardNames_mc.addChild(my_image);
          }
         
      //preloader
      /*function loop(e:Event){
                  picHolder_mc.removeChildAt(0);
                  if(this.numChildren!=0){
                      var k:int = this.numChildren;
                      while( k -- )
                      {
                          this.removeChildAt( k );
                      }
                  }
                  picHolder_mc.addChild(preloader);
                  preloader.width = 50;
                  preloader.height = 47.5;
              }*/