JOR wrote:
Below is my test class of trying to pragmatically add a set of radio buttons to an ActionScript 3.0 project. Do you see anything I may have done incorrectly? When I run it, I don't get any compile errors but I also don't see any radio buttons.
If memory serves, in Flex, the application root should be used as the parent container for UIComponent or its extensions and UIComponent or an extension should be used as the primary display container ... or something like that. Everything I say is true, modulo something :) I think there is a good blog post on this somewhere; I'll look it up.

In the mean time, a quick and minimal hack (and I do mean hack),

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" width="400" height="300" creationComplete="TADemo.Main(this)">
</mx:Application>



package
{
 import mx.controls.TextArea;

 // simple TextArea Demo
 public class TADemo
 {
   private var __textArea:TextArea;
public function TADemo(_parent:Object)
   {
     __textArea        = new TextArea();
     __textArea.width  = 200;
     __textArea.height = 20;
     __textArea.x      = 10;
     __textArea.y      = 10;
__textArea.text = "This is a test"; _parent.addChild(__textArea); }

   public static function Main(_myRoot:Object):void
   {
     var instance:TADemo = new TADemo(_myRoot);
   }
 }
}

Here is an example using a custom CheckBox class that dynamically draws a check box thingy and uses a TextField for the label.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" width="400" height="300" creationComplete="display()">
 <mx:Script>
   <![CDATA[
     public function display():void
     {
         import mx.core.UIComponent;
var __cBox:CheckBox = new CheckBox("Click Me");
       var __myReference:UIComponent = new UIComponent();
addChild(__myReference);
   __myReference.addChild(__cBox);
     }
   ]]>
 </mx:Script>
</mx:Application>

The CheckBox class extends Sprite. It contains an icon (instance of another class that draws the check box icon) and a label. After creating these elements, the constructor calls

addChild(__icon);
addChild(__label);


Haven't had my afternoon coffee, so I hope this helps more than confuses!

- jim

--
Singularity >> Flash :: Flex :: Math :: www.2112fx.com/blog
TechNotes >> Computational Geometry :: www.2112fx.com/technotes.html


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to