A few suggestions:
- don't set explicitWidth in updateDisplayList, use setActualSize()
- like Alex said, Container does extra processing, so use UIComponent as
the base of both ParentView and ChildView. SInce you are managing the layout
of the children manually and you don't require scrolling or clipping these
componentns you don't need to overhead of Canvas
- take out the updateDisplayList method of ChildLayoutContainer. Instead,
use the built in layout stuff in VBox by setting the percentWidth property
of the chioldren when you add them. Your method adds an additional
uneccessary loop over all the children.
- use UITextField instead of Label if appropriate. THe UITextField class
is a bit faster when it comes to measurement and layout. Label adds the
ability for the text to be truncated with ..., but that's about all you get.
So if either you a) don't care if the text has ... or is simply cut off or
b) the text doesn't need truncation (like for your numbers) then use
UITextFiled instaed of Label
- No need for the call to invalidateDipslayList in addChildView method in
ParentView. This probably doesn't add much to the total time, but it's an
uneeded call (adding a child automatically invalidates)
With some modifications I got your sample running in under 300 milliseconds.
If I converted to UITextField objects that got down to under 200
milliseconds (using UITextField and the textWidth property for measurement).
Doug
On Fri, May 30, 2008 at 10:21 AM, Alex Harui <[EMAIL PROTECTED]> wrote:
>Containers are heavy. They measure their children, think about
> clipping and scrollbars, compute the size and position of children, think
> about borders, background colors and more. If you aren't using 80% of those
> features, then you shouldn't be using a container.
>
>
>
> A UIComponent can be easily subclassed to position its children
> vertically.and won't spend time thinking about those other things.
>
>
> --
>
> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *christian.menzinger
> *Sent:* Friday, May 30, 2008 9:04 AM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Performance issues while creating several
> instances of DisplayObject at the same
>
>
>
> Hi there,
>
> while experimenting with Containers and UIComponents I received very
> strange results. Is it possible that the instantiation and rendering
> of about 150 DisplayObjects can take up to 3 seconds of processing time?
>
> I have a very light weight application attached where 20 views
> (containing a Label and a VBox) and in average 4 child views
> (containing 2 Labels next to each other) are instantiated and rendered
> at the same time.
>
> The rendering of 1000 native FlashObjects like TextField in a pure
> AS-Project takes about 95ms(!) to update the display!
>
> The performance differs extremely if you don't set any width on the
> parentViews.
>
> Could you please check if I have overseen something or used bad code?
> It would be great to get a hint how to increase the overall
> performance. I need a solution which increases rendering performance
> as much as possible and allows me to use text truncation and dynamic
> setting of widths.
>
> Thanks a lot in advance for everything that could lead me into the
> right direction.
>
> view sample Application (could download source by right clicking)
>
> http://www.metadudes.com/samples/flex/performance_issue/LightWeightChildCreation.html
>
> BR,
> Chris
>
>
>