Hi All

I'll try keep this brief, but wanted to get feedback and opinions on  
a number of issues which I have run into.  I'll be touching on

o Issues with getting a TileList to redraw/refresh the tiles
o Selection issues and differences between selections made by a user,  
or programmatically.
o Binding and redraw issues.
o Pose questions about approaches for best performance (also related  
to binding)
o Show you an interesting problem I am hoping to re-implement after  
the binding feedback where I want my TileList to do some complex  
resizing of the tiles.

I am working on an app that besides being under NDA, its too big to  
show any working parts that demonstrate some of these performance and  
drawing issues, but over time I have started to be bothered by some  
things that make me feel like I'm doing something fundamentally wrong  
in some cases.

So here is a little app that although a bit contrived does manage to  
touch on some of the issues I want to shed some light on.

http://labs.lhsw.com/~cgalpin/flex/Problem/bin/Problem.html

Right click to see the source.

Its a simple little app [1] that loads some xml data, creates a  
Product object [2] that gets put into a Arraycollection which is used  
as a dataProvider for a few views. It has a thumbnail and detail view  
which shows the products in a TileList and shows a "detailed view" on  
the current selection. You can switch to a grid view to see the  
products in a very basic grid, and the selections are maintained  
across views.  In both views you can change the name and price of the  
selected products and also delete/undelete the selected products. The  
TileList has a slider and checkbox that are mostly unimplemented  
right now (see below for what they are for). There is a little status  
panel near the bottom that shows selection states to help you keep  
track of some of that stuff.

I set this up to be able to show some issues I have run into, and get  
feedback on work arounds or t see what I am doing right/wrong in  
certain situations.  The general idea is I want to be able to modify  
the data properties (including adding and removing products) and have  
the views redraw/update appropriately.

Here are some of the issues this app shows - let me know your thoughts.

1. Tiles not redrawing properly. Select all tiles and click delete,  
then undo delete.  You'll see the thumbnail labels dont draw until  
you scroll or resize. Even in my brain dead little thumbnail  
implementation this is an issue. My real app thumbnails are far more  
complex.

2. Odd issues related to selections. In general what I have  
implemented works, however there are some subtle issues related to  
programmatically setting the selectedIndex and/or selectedIndices  
that you will see if you look at the status output. First you'll see  
the selectedIndex changes when setting selectedIndices (just switch  
views to see). Even if you set the selectedIndex, the selectedIndex  
will be -1 but when set to the other list, it gets changed to 0. But  
also after  programmatically setting the selectedIndices you cannot  
uses the shift key to extend selections. you have to start with a  
user driven single select to reset state and then can use shift. you  
can use ctrl though. odd stuff. I think there are some bugs here.

Do you have better ideas on how to maintain the selections without bugs?

3. Binding issues. We have seen performance problems with out app  
once there are thousands of thumbnails and I want to resolve them.  
Currently it's using XML objects in an XLListCollection and we get a  
lot of "free" binding with that which is nice, but I think the  
binding to xml objects is a big part (we see lots of events firing  
off causing lots of extra work when we don't expect it) as well as  
the wieght of the thumbnail object.  So, in this demo I use pure  
objects and show 2 ways of trying to maintain state.

    The binding works as expected - see setting the price for  
example, but I fear this could be a performance issue for us. If you  
update 5 properties as part of an operation, you only want one event  
thrown to have objects redraw, not 5 of them.  Also you'll see I had  
to pass the price to the ProductImage::getOverlayPrice method in  
order to get it to fire. In the real world you end up having to pass  
all properties in that are depended on, and every change causes that  
method to be called which can get expensive when really it only  
needed to be called once. Ideally I'd like to be able to update  
Product object and when done, throw an event that signals the redraw  
- see next.

    The name is not bindable, so after changing it, I have tried a  
variety of ways to refresh the TileList and the details view, but  
they never refresh. The grid refreshes on invalidateList(), but it  
contains no custom renderers right now and I fear that will change  
once I do. but if I can just force a redraw/refresh when something  
changes, this may be a better approach.

Besides getting the non-binding approach to work, what's going to  
give me the best performance? Can i use binding but limit the amount  
of work done for the actual event on change, and only aply the  
changes in updateDisplayList()? I'd like to pick a strategy to take  
when beefing up my thumbnail implementation. Remember there could be  
thousands of products and I could apply a half dozen property changes  
to all of them in one operation (think apply a discount or something)  
and want that to be reflected in all views efficiently

4. Last but not least, my real app has a pretty cool way of showing  
the thumbnails. Instead of the slider driving the width of the tile,  
it actually drives the width of the image on the tile. So instead of  
being a fixed 60x60 as they are now, when you slide the slider the  
image width changes, forcing the tile to redraw accordingly. The most  
significant effect is that since we maintain the aspect ration on the  
image, the height increases as well. Then, the checkbox can be  
selected, and instead of the thumbnail images all being the same  
size, they are drawn to their relative size. So the largest width and  
height are computed and then the number pixles per inch are  
determined and they are all drawn scaled to that. This lets you see  
the relative size differences.  It realy looks cool.  I have this  
working in my existing app by extending TileList but I think my  
meddling may be influencing/exhasperating  some of the redrawing  
problems I occasionally get (like #1 above for example). Once I get  
some feedback on the approach to take for handling binding I want to  
implement that in this demo and get feedback. if you have any  
thoughts before then, please let me know. I just don't want that to  
cloud the issues the simple cases already exposes.

Hopefully someone will just show me I'm doing something stupid for  
all of the above!

Thanks for reading this far and have a good weekend,
charles

[1] Please ignor stuff like the creationPolicy="all" on the ViewStack  
- just wanted to put something quick and dirty to get my point  
across. No effort has been made to show best practices for the most  
part, and I'm open to any feedback - just don't let it distract you  
from the issues I am after.
[2] One of my goals is too see how hard it will be to convert out app  
from using XML as the underlying objects in an XMLListCollection to  
using pure objects - to resolve memory leaks and improve performance.

Reply via email to