PDA

View Full Version : Force redraw of itemRenderer after property change


Jesse
09-04-2006, 12:53 PM
Yup, I'm learning Flex. Started last weekend and have done a few hours so far, in dribs and drabs. And yup, I love it.

Simple question: how do I force a TileList to re-draw its itemRenderers?

Detailed version:

Just to jump in at the deep-end I set myself the following task: I want to extend TileList to make a version which will iterate over all its itemRenderers and call a function on them. This much I've achieved.

I have my extended TileList class, and when I call a specific function, it iterates over all itemRenderers in itself, and calls a function on them. The itemRenderers themselves are just simple componentized image displays with a preloader. The function I'm calling, for the moment, sets the width and height of the itemRenderer via a public method the itemRenderer exposes.

When I run this whole setup, the TileList should iterate over its items, resize them all, and then redraw itself with smaller itemRenderers. It all works except the last bit. I cannot seem to get the damn thing to redraw. If I trace the dimensions of the itemRenderers after the iteration, they've been (theoretically) resized, but they don't visually resize.

I've tried validateNow() and invalidateSize() on the TileList and on each of the itemRenderers. No dice.

hangalot
09-05-2006, 03:36 PM
invalidate() should do the trick.

Jesse
09-06-2006, 02:41 AM
Against which element sorry mate? It doesn't seem to be a valid method for the itemRenderer or the TileList.

hangalot
09-06-2006, 02:39 PM
yeah my mistake, was thinking flex 1.5. validateNow does the same in flex 2 :(

when are you looping through these components?

Jesse
09-12-2006, 12:31 PM
I was looping through them when-ever a click event was registered. I tried a raft of ways to do it, but couldn't get it to work. In the end I realized however, in this case it wasn't necessary. My ultimate goal was to resize all the tiles in the TileList on the basis of user input, and I discovered I can of course do this by simply manipulating the number of columns/rows and their width/height using code such as follows.

Thx for the help hangalot.

private function sliderChange(target:TileList, event:SliderEvent):void {
var currentSlider:Slider=Slider(event.currentTarget);
target.columnCount = Math.floor(target.width/currentSlider.value);
target.rowHeight = Math.floor(target.height/currentSlider.value);
target.columnWidth = currentSlider.value;
target.rowHeight = currentSlider.value;
}

cardCounter
11-25-2008, 03:41 PM
Hi, new to the forums.

You mentioned calling invalidate() ( I don't see such a function in flex 3 either)

What about dispatching a new FlexEvent.INVALID on the component? Would that be the same thing as moving around elements, which probably calls some flex event which invokes UpdateDisplayList()?

Ive got a similiar problem involving hierarchy of DisplayList calls on dynamic children.

hangalot
11-25-2008, 03:45 PM
invalidateDisplaylist, size or another one. pick the one best suited to your needs.

dr_zeus
11-25-2008, 04:50 PM
How exactly are you resizing the item renderers? Just setting width and height isn't going to work. The TileList will just redraw itself and reset their sizes to whatever the internal algorithm decides is the best fit. Your best bet is probably to use some combination of columnWidth, rowHeight, columnCount, and rowCount on the TileList.