Hi
setting the target.setContentSize at the end of the updateDisplayList method
in my custom layout
to enable correct scrolling results in an infinite recursion call of the
updateDisplayList method
My custom layout is based on BasicLayout
I only use the ILayoutElement interface to position, size etc. elements
the layout is used by a spark List component with virtualLayout set to false
it only happens when I
1) use target.setContentSize and
2) resize the application window (the List has a percent height)
(otherwise the layout works as expected)
I do not understand why that re-invalidates the displayList infinitely..
The application is an AIR Desktop application and I compile with 4.12 RC1
(although i tried to compile with 4.11 and 4.10 with the same results)
Someone has a glue why this happens or had already the same problem?
thx for suggestions
############ updateDisplayList implementation ################
public override function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void {
var count:Number = target.numElements;
var _vGap:Number = verticalGap;
if(count > 0) {
var elWidth:Number =
typicalLayoutElement.getLayoutBoundsWidth();
var elHeight:Number =
typicalLayoutElement.getLayoutBoundsHeight();
var totalHeight:Number = count*elHeight +
verticalGap*(count - 1);
var xLeft:Number;
var xRight:Number;
xLeft = 0;
xRight = unscaledWidth - elWidth;
if(totalHeight > unscaledHeight) {
//make it vertically overlaping
_vGap = -elHeight/2 + verticalGap;
}
var layoutElement:ILayoutElement;
var xPos:Number = 0;
var yPos:Number = paddingTop;
var _cHeight:Number;
for(var i:int = 0; i < count; i++) {
layoutElement = target.getElementAt(i);
layoutElement.setLayoutBoundsSize(NaN,NaN);
if(i % 2 == 0) {
xPos = xLeft;
} else {
xPos = xRight;
}
_cHeight = yPos + elHeight;
layoutElement.setLayoutBoundsPosition(xPos, yPos);
yPos += elHeight + _vGap;
}
var cWidth:Number = Math.ceil(xRight + elWidth);
//try to call it only when the content size has
changed - but produces
the same result
if(target.contentWidth != cWidth ||
target.contentHeight != _cHeight) {
target.setContentSize(cWidth,
Math.ceil(_cHeight));
}
//produces an infinte recursion loop and hangs
the application
//target.setContentSize(cWidth, _cHeight);
}
}
--
View this message in context:
http://apache-flex-users.2333346.n4.nabble.com/Infinite-recursion-in-custom-layout-tp5148.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.