Sunday, May 30, 2010

FocusManager getIndexOfNextObject in Flex Application

mx.managers::FocusManager/getIndexOfNextObject

Error means FocusManager is looking for mxml component to set focus, when hit tab from flash object and fun part you don't have any mxml component to set focus.

Here is the trick create mx.button component and setStyle to null. It will invisible and focus manager can find the component to focus. Now application won't crash or hung.

myButton.setStyle('skin', null);

(mx:Button skin='{null}' )

.myButtonStyle {
skin: ClassReference(null);
}

(mx:Button id="myButton" styleName='myButtonStyle')

Enjoy.

Friday, May 21, 2010

Dynamically resize nested Flex List with variableRowHeight

I was stuck recently with a Flex component that had a List with an itemRenderer. The itemRenderer contained another List with an itemRenderer. Now the problem with this is that the data had unique counts and the lists had variable row heights (variableRowHeight = true). The result was that containers would not dynamically resize enough to display the whole List. In other words, the List was clipped and vertical scroll bars were displayed.

Sounds familiar to me when I had same problem as above developing comment component. I found solution in following blog

1. Link to the reference blog


2. You can also visit another blog post with good example for same problem

Bryan Bartow


Hope that helps.

Sunday, May 2, 2010

Dynamically change height of TileList

You have to adjust rowCount of Tile List to make height according to data at runtime. In below example if column count is 1 you rowCount="data.length()". Now data can be XML children.length() or array.length or any data length.

[mx:TileList id="_videoList" rowCount="{data.length()}" updateComplete="changeHeight"]

You can also updateComplete if you have column count more than 1.

private function chanegHeight():void{
var rc:int = Math.ceil(data.length() / _videoList.columnCount);
if (_videoList.rowCount!=rc) _videoList.rowCount = rc;
}

Cheers,
Nehul