2 Replies Latest reply on Oct 28, 2007 1:32 AM by cornflex

    accessing images at run time

    cornflex
      Hi

      I am trying to create Images at run time.
      I am using a while loop , in which i create images.
      The function code is :

      private function add_image():void {

      var i:int = 0 ;
      var p:int = 0 ;
      while (i < 5) {

      var img:Image = new Image();
      this.addChild(img);
      img.source="c:/Winter.jpg";
      img.width=250;
      img.height=200;
      img.x = p ;
      img.id="img" + i ;
      p = p + 250 ;
      i++;
      }

      }

      I have another function in which i want to change some properties of the image
      i created in the previous function.

      function alter_image():void{

      img3.height=50;
      }

      img3 was suppose to be created in the first function by : imd.id = "img" + i ;
      The problem is that when i try to run the project i get this error :
      "1120: Access of undefined property img."

      How can i prevent this problem ?

      thanks !