1 Reply Latest reply on Dec 22, 2009 8:58 PM by ShardulSingh

    Image inside a UIComponent

    Flex_ Level 1

      How can I display an image inside a UIComponent (or a Sprite for that matter)?

      I have a custom UI Component .. I am adding an Image and textField to this component. When I add this component to the Canvas .. thje Image is not displayed.


      Please help me to resolve this issue. Thanks in advance.

        • 1. Re: Image inside a UIComponent
          ShardulSingh Level 3



          For image inside the sprite find the link below.


          And for image inside the UIcomponent find the code below.



          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
              layout="absolute" creationComplete="onCreationComplete()">
                  import mx.core.UIComponent;
                  import mx.controls.Image;
                  private function onCreationComplete():void
                      var uiComp : UIComponent = new UIComponent();
                      uiComp.width = 400;
                      uiComp.height = 400;
                      var img : Image = new Image();
                      img.source = "rose1.jpg";
                      img.width  = 300;
                      img.height = 300;
                      uiComp.addChild(img as DisplayObject);
              <mx:Canvas id="can" width="500" height="500"/>




          with Regards,


          Shardul Singh Bartwal