Thanks I thought that always initialising either in the constructor or in the variable declaration was a bit hacky. It is what I've been doing up till now. Is there any refrence for a component (particualy containers) life cycle?
Off topic in gmail I autoarchive flex coders emails. Does anyone know of a way to not auto archive treads that I've been involved with? Regards, Wesley Acheson On Tue, Mar 10, 2009 at 5:40 PM, Tim Hoff <[email protected]> wrote: > > 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 [email protected], 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. > > > > > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups > Links > > > >

