Override createChildren() and add the child there; instead of trying to re-invent the component lifecycle by using INITIALIZE . And yes, commitProperties() would be a good place to set the child's text; from the text property.
-TH --- In flexcoders@yahoogroups.com, Wesley Acheson <wesley.ache...@...> wrote: > > Hi take for for example the following simple example. Its not a real world > example but it does show the problem that I wish to avoid. > > --------------------------- > MXML (simpletest.mxml) > --------------------------- > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" > xmlns:local="*"> > <local:SimpleExample text="hello"> > > </local:SimpleExample> > </mx:Application> > > ---------------------------------------------- > ActionScript SimpleExample.as > ---------------------------------------------- > package > { > import mx.containers.VBox; > import mx.controls.TextInput; > import mx.events.FlexEvent; > > public class SimpleExample extends VBox > { > > private var child:TextInput; > > private var _text:String; > > public function SimpleExample() > { > addEventListener(FlexEvent.INITIALIZE, init) > } > > private function init(event:FlexEvent):void > { > child = new TextInput(); > addChild(child); > } > > public function get text():String { > return _text; > } > > public function set text(text:String):void { > this.child.text = text; > } > > } > } > -------------------------------- > If this is run I get a null error at set text. How do I avoid this? Should > I just just listen to the property change event on set text? Imagine now > that I had multiple different children. Is there a method I can override > such as commitProperties so that all this will be done in the same place. > > I'm sorry if this isn't too clear what I asking. > > Wesley Acheson. >