3 Replies Latest reply on May 26, 2011 3:53 PM by Flex harUI

    Caching images in runtime for textflow or text area

    vdatgram

      Hi,

       

      I am building a chat app, each user has a picture.  So each time a user talks, I display their picture along side with what they typed.  I only know the URL of the picture at run time.  Here's what I'm trying to do:

       

       

       

      var p:ParagraphElement = new ParagraphElement();
      img = new InlineGraphicElement();
      img.source = "http://www.something.com/image.jpg";
      img.height = 40;
      img.width = 40;
      p.addChild(img);
                          
      var s:SpanElement = new SpanElement();
      s.text = "Username: ";
                          
      p.addChild(s);
      
      textArea.textFlow.addChild(p);
       
      

       

       

      The above code shows the image fine.  However, the moment I add these lines:

       

      var p1:ParagraphElement = new ParagraphElement();
      p1.addChild(img);
      

       

       

      The first image disappears...  How do I reuse that orginal image element?

       

      Thanks!