0 Replies Latest reply on May 31, 2008 10:36 AM by brmcc

    Adding a CheckBox to a Sprite

      I would like to be able to add a CheckBox to a Sprite, or failing that, a UIComponent. However *if* this is possible, I must be doing something wrong as illustrated in the code below. Adding the CheckBox to the Sprite produces no visible results. Also note that when adding a CheckBox to a UIComponent, its height/width must be set explicitly in order for it to render properly.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"

      import mx.controls.CheckBox;

      public function initApp():void
      // 1. This works as expected
      var inPanel: CheckBox = new CheckBox();
      inPanel.label = "inPanel";

      // 2. This works, but if height/width not explicitly
      // set then the label is displayed only as a tooltip
      var inUIC: CheckBox = new CheckBox();
      inUIC.label = "inUIC";
      inUIC.x = 80;
      inUIC.height = 40; // If not set, no label
      inUIC.width = 80; // ditto

      // Add a Sprite to parent a checkbox
      var theSprite: Sprite = new Sprite();
      theSprite.x = 160;

      // 3. This doesn't work, no compile or runtime
      // error -- it just has no runtime effect
      var inSprite: CheckBox = new CheckBox();
      inSprite.label = "inSprite";

      <mx:Panel layout="absolute" title="Add Controls" id="thePanel">
      <mx:UIComponent width="300" height="300" id="theUIC"/>