angie
09-24-2008, 02:02 PM
I have read that for improved performance you should add children off the display list so that it doesn't have to re-measure etc. Am I right in assuming that this means adding children bottom up, for example
var t:TextInput = new TextInput();
var h:HBox = new HBox();
h.addChild(t);
var p:Panel = new Panel();
p.addChild(h);
addChild(p);
offers better performance than the following?
var p:Panel = new Panel();
addChild(p);
var h:HBox = new HBox();
p.addChild(h);
var t:TextInput = new TextInput();
h.addChild(t);
This makes sense to me. However, if these were all custom components, eg MyPanel, which in it's createChildren it adds MyHBox, and in it's createChildren it adds TextInput, doesn't that mean that we lose control over this and the line var p:MyPanel = new MyPanel(); will mean that everything is added to the display list top down?
The reason I ask is that I have a custom ActionScript component that loops through a definition and adds children. Some of these child components extend HBox and have children of thier own, some simply extend TextInput. In my test it is adding 47 children and it is taking a second to display, which is not acceptable performance. Is this an expected duration or is there anything I can do to affect the order that the children are added to improve performance?
Thanks
var t:TextInput = new TextInput();
var h:HBox = new HBox();
h.addChild(t);
var p:Panel = new Panel();
p.addChild(h);
addChild(p);
offers better performance than the following?
var p:Panel = new Panel();
addChild(p);
var h:HBox = new HBox();
p.addChild(h);
var t:TextInput = new TextInput();
h.addChild(t);
This makes sense to me. However, if these were all custom components, eg MyPanel, which in it's createChildren it adds MyHBox, and in it's createChildren it adds TextInput, doesn't that mean that we lose control over this and the line var p:MyPanel = new MyPanel(); will mean that everything is added to the display list top down?
The reason I ask is that I have a custom ActionScript component that loops through a definition and adds children. Some of these child components extend HBox and have children of thier own, some simply extend TextInput. In my test it is adding 47 children and it is taking a second to display, which is not acceptable performance. Is this an expected duration or is there anything I can do to affect the order that the children are added to improve performance?
Thanks