2 Replies Latest reply on Feb 26, 2008 4:47 AM by m_hartnett

    Images going over the top of each other?

    jefflemon Level 1
      Hi,

      In a result handler I have this:
      //add profile image
      var profileImg:Image = new Image;
      profileImg.source = (profileImage);
      profileImageContainer.addChild(profileImg);

      It creates a profile image, the only problem is, when the result hadler is called again it puts another image over the top, is there any way I can get it to get rid of the old image befor the new one is added?
        • 1. Re: Images going over the top of each other?
          SujitG Level 2
          Try removing the addChild part from the result handler or use the removeChild()/removeAllChildren() method and remove the profileImg object and then add it again.
          Hope this helps.
          • 2. Re: Images going over the top of each other?
            m_hartnett Level 3
            If you are trying to add the image to the container the first time and update source in subsequent result handler calls you can put an if statement to check if the image exists in the container.

            To do this add - profileImg.id = "someName"
            Then you can do:
            if(profileImg.getChildByName("someName") != null)
            profileImageContainer.addChild(profileImg);

            profileImageContainer.source = setTheSource.

            This way you are only adding the image once but updating the source whenever it changes.