1 Reply Latest reply: Apr 22, 2009 5:53 AM by Ned Murphy RSS

    Loading images in loop and resizing!

    rahimhaji Community Member

      Dear Friends,

       

      iam creating a pallete,  in that i have a class movieclip with 1 image and 2 text (title, desc). Here iam connecting a xml and creating the same class and adding it to the scrollpane. in that each item (movieclip) i need to load images and fill the text. iam filling the text and loading the images. but i need to scale the pictures to 35x35. actual size of the pic is 70x70.

       

       

      my code is :

       

      function fillitem() {
          var ypos:Number = 10;
          //reptitle.text = myxml.toptitle;

       

          reptitle.text = options[0][0].tit;
          var tf1:TextFormat = new TextFormat();
          tf1.color = options[0][0].col;
          tf1.size = options[0][0].siz;
          tf1.bold = options[0][0].bol;
          reptitle.setTextFormat(tf1);
          for (var j:int=0; j<=len-1; j++) {
              var titem:MovieClip = new mastertxt();
              titem.y = ypos;
              titem.dumbtn.flag = j;

       

              //--- Loading Image - starts -----------------------------
              var pictURL:String = imgarray[j];
              var pictLdr:Loader = new Loader();
              var pictURLReq:URLRequest = new URLRequest(pictURL);
              pictLdr.load(pictURLReq);
              pictLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, onInit);
              function onInit(evt:Event):void {
              titem.img.scaleY =titem.img.scaleX;
              titem.img.width = 35;
              titem.img.addChild(pictLdr);
              }

              //--- Loading Image - ends -----------------------------
              titem.txt1.text = titarray[j];
              titem.txt2.text = comarray[j];
              var tf2:TextFormat = new TextFormat();
              tf2.color = titcolarray[j];
              tf2.size = titsizearray[j];
              tf2.bold = titboldarray[j];
              titem.txt1.setTextFormat(tf2);
              titem.txt1.autoSize = TextFieldAutoSize.LEFT;

       

              var tf3:TextFormat = new TextFormat();
              tf3.color = comcolarray[j];
              tf3.size = comsizearray[j];
              tf3.bold = comboldarray[j];
              titem.txt2.setTextFormat(tf3);
              titem.txt2.autoSize = TextFieldAutoSize.LEFT;

       

              holder.addChild(titem);

       

              ypos = ypos + titem.height;
          }
          scrpane.source = holder;
      }

       

      Here it loads the images in the last box only. i need for all.. pls help me to load the pic in loop and resize it i got struct up...

       

      Thanks and Regards,

      Syed Abdul Rahim