Mike, I am wondering if what I am experiencing with createChildren() is similar to what you've described below. I am subclassing UIComponent - and I read that it is best to create children in a createChildren() method.
However, I am tying into someone else's existing code and she has done some nice work with loading state. Her code creates a new instance (of the class mentioned above that extends UIComponent - let's call it BTProcess). What I am finding is that after the instantiation, the new object is having properties set ON children that have not yet been instantiated and hooked up to BTProcess. I am guessing that I could have the state-loading code broken into two parts: one the instantiates and one that listens for CREATION_COMPLETE event before setting properties. But I am wondering if there is a faster way to do this. So, my question is does your approach address this by creating children in commitProperties() and does this provide a work-around to the problem that I am experiencing. Thanks! -Eric --- In flexcoders@yahoogroups.com, "Michael Schmalle" <[EMAIL PROTECTED]> wrote: > > Well, > > Basically, if you subclass a UIComponent or decendent, and you are making a > component that uses setters that 'communicate' with composite children, I > would always use this algorithm. > > As far as the randomness, might have to do with bindings, other timing > issues. If you set a property in mxml it will always be called before > children are created, you can count on that. > > Mike > > On Thu, Sep 18, 2008 at 6:57 AM, Manu Dhanda <[EMAIL PROTECTED]>wrote: > > > > > Thanks for the answer Mik. > > > > But, Isn't it strange that this situation can occur randomly?? > > Or is there any particular case, when we always need to use the solution, > > like the one you provided. > > > > I am asking it because I had written other components in my code where > > everything is working seamlessly and I am worried now as if they are error > > prone?? > > > > Thanks, > > Manu. > > > > > > Michael Schmalle wrote: > > > > > > Hi Manu, > > > > > > This is a pretty simple answer. The reason is the mxml properties get > > > looped > > > into your component before createChildren() creates the child > > descriptors. > > > > > > This is why we need the invalidation system. You need the following. > > > > > > public function set data(value:ArrayCollection) { > > > _data = value; > > > dataChanged = true; > > > invalidateProperties(); > > > } > > > > > > ... in the same class > > > > > > override protected function commitProperties() > > > { > > > super.commitProperties() > > > if (dataChanged) > > > { > > > // do things with child components IE > > > myGrid.data = _data; > > > dataChanged = false > > > } > > > } > > > > > > > > > Setting your child properties in commitProperties() guarantees your > > > children > > > will be created. > > > > > > Peace, > > > Mik > > > > > > > > > > > > On Thu, Sep 18, 2008 at 3:09 AM, Manu Dhanda > > > <[EMAIL PROTECTED] <manuraj.dhanda%40gmail.com>>wrote: > > > > > >> > > >> Hii Guyz, > > >> > > >> I am having some strange issue here. > > >> > > >> What I am doing is: > > >> > > >> <comps:CustomUIComponent Data="{_dataP}"/> > > >> > > >> I am using this component in some abc.mxml as above. > > >> > > >> Data is something like: > > >> > > >> public function set Data(value:ArrayCollection){ > > >> //set ur data here. > > >> } > > >> > > >> But strangely, when I do it(pay attention to bold mxml code of line > > above > > >> now), I find one of flex components (say a Grid) in my CustomUIComponent > > >> as > > >> null, on which I want to set this Data. > > >> > > >> Now, I am worried like how a method, say "set Data" can be called before > > >> even creation complete of CustomUIComponent. > > >> > > >> Can someone please put some light here.. > > >> > > >> Thanks, > > >> Manu. > > >> > > >> -- > > >> View this message in context: > > >> > > http://www.nabble.com/UI-component%2C-a-set-function---creationComplete- tp19547254p19547254.html > > >> Sent from the FlexCoders mailing list archive at Nabble.com. > > >> > > >> > > >> > > > > > > > > > > > > -- > > > Teoti Graphix, LLC > > > http://www.teotigraphix.com > > > > > > Teoti Graphix Blog > > > http://www.blog.teotigraphix.com > > > > > > You can find more by solving the problem then by 'asking the question'. > > > > > > > > > > -- > > View this message in context: > > http://www.nabble.com/UI-component%2C-a-set-function---creationComplete- tp19547254p19550295.html > > Sent from the FlexCoders mailing list archive at Nabble.com. > > > > > > > > > > -- > Teoti Graphix, LLC > http://www.teotigraphix.com > > Teoti Graphix Blog > http://www.blog.teotigraphix.com > > You can find more by solving the problem then by 'asking the question'. >