views:

89

answers:

2

Hi

I have a canvas called Host with many UIComponents as children, sometimes up to 1000 or 3000 items. This is fine for now, as they are not interactive.

But, I have added a 'marker line' (a 1 pixel wide UI Component with a colored background) to the canvas which follows the mouse movement. When this UIComponent is added to the Host canvas and moves, everything slow down to a crawl i.e. takes ages for the UIComponent to move.

What do you think could be causing this? or how to avoid?

+1  A: 

Every time you move the mouse, you are probably causing the measure and updateDisplayList methods of every one of those UIComponents to be called. So you may be causing those thousands of components to renegotiate their positions and dimensions with their neighbors.

Without seeing your code I can't get too specific in recommending a solution, but you might try placing a Canvas with a transparent background over the canvas that houses the thousands of components, matching its dimensions and location, and use that to move the marker line.

Robusto
Overwrote the updateDisplayList function for the canvas, and sure enough, its getting called each time I move the UIComponent, which in turn calles layout functions for all the other components. The transparency canvas gets around this. Good man.
Brian Bishop
A: 

I assume of your 1000 items, only a small portion are on the screen at one time?

If you have that many components, a slow down is expected. I suggest looking into using a ListBased Class. Therefore only the items on screen are renderered and you will not have a lot of components hanging out in memory.

www.Flextras.com
I neeeded to use a canvas to set the x,y for each display object. Think I might be able to prevent offscreen items being rendered by using an 'itemRenderer pool', similar to how the List works.
Brian Bishop