3 Replies Latest reply on Sep 24, 2009 12:09 PM by paul.williams

    Adding an image to a UIComponent

    SiHoop Level 1

      I'm experimenting with a UIComponent to display some images:

      private var spriteBg:UIComponent=new UIComponent

       

      I can use pictLdr

      private    var pictLdr:Loader = new Loader();

       

      or draw with 'graphics' to display the images, but I cannot use myImage

      private var myImage:Image

       

      Is this because myImage has not loaded or that I cannot load myImage into the UIComponent?

      Here's what I'm doing:

       

      //Works

          pictLdr = new Loader();
          var pictURL:String = "pics/checkmark_green.png"
          var pictURLReq:URLRequest = new URLRequest(pictURL);
          pictLdr.load(pictURLReq);
          spriteBg.addChild(pictLdr)

      //Works

          spriteBg.graphics.beginFill(0xff0000);
          spriteBg.graphics.drawRect(0,-30,10,10);  

      //Will not work

          myImage=new Image()
          myImage.source="@Embed('pics/checkmark_red.png')"
          spriteBg.addChild(myImage)