3 Replies Latest reply on Jan 18, 2010 10:40 PM by Flex harUI

    Adding content to a UIComponet

    SiHoop Level 1

      I need to wrap a text field in a container for a reason that I won't get into, but I'm having a problem making the container appear on stage. In the code below I create a Text object using AS, then I create a UIComponent. Finally, I add the Text object to the UIComponent and add the UIComponent to an existing HBox. However, the Text object does not appear. Can I add the Text object to a container and still have it appear on stage inside the HBox?

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"   creationComplete="init()">
          <mx:Style  source="styles/styleSheet.css" />
          <mx:Script>
              <![CDATA[
                  import mx.core.UIComponent;
                  import mx.controls.Text;
      private function init():void{
          var spellingExplanation:Text=new Text;
          spellingExplanation.text="Possible spelling error";
          var textContainer:UIComponent = new UIComponent();
          textContainer.addChild(spellingExplanation);
          scoreCard.addChild(textContainer);
      }
              ]]>
          </mx:Script>
          <mx:HBox id="scoreCard" horizontalCenter="0">   
              <mx:Text   text="Total Characters" selectable="false"  styleName="buttonStyle1"/>
          </mx:HBox>
      </mx:Application>