On 7/29/13 11:56 AM, "OmPrakash Muppirala" <bigosma...@gmail.com> wrote: >>> >> >The user still needs to keep track of the index length chrome elements >>and >> >regular elements. >> I don't think I'm understanding this. >> > >If I want to add an element as a chrome, I will need to know the number of >elements already added as chrome so that I can figure out the index that I >want. Same for elements added as normal childs. There are two different >indices because internally we are adding to two different containers >(this.addChild() vs. actualParent.addChild()) How do we make this clear >to >the API user? > >I guess I am worried about making it easier for folks to trip over >themselves. >Two API calls with same signatures means it is reasonably obvious to the >user even if there are chances for runtime errors. >Two API calls with different signatures (IChrome vs. DisplayObject) means >that any problems will be caught at compile time Ah, I get it. Good point. Just having a numElements property won't cut it. I guess we could have a getNumberOfElements(flags) that returns different numbers based on the same flags you would have put on the objects. And maybe a getElements(flags):Array which returns the array of children matching that flag (and the array is not watched).
Another option is to have a chrome sub-object on containers with their own addElement API. We wouldn't do that for controlBarContent because you want that to be an array for MXML purposes, but the chrome object wouldn't be an array, just a sub-object with methods. The flag approach has the advantage of not forcing all non-content objects to be "chrome". The flags can be "anything" so other folks can do different things with different flags. In my current thinking, there is an API for everybody which affects the content of the container, and a "doesn't have to be quite as obvious or easy" API for the chrome developer for the container. The "API for everybody" makes me want to only have addElement/numElements in the API and use flags for chrome/component developers. But again, I am still undecided and find all of your feedback quite useful. -Alex