Get the type of an Object
There is many ways to get the type of any object in Flex, but no one is simple and works in all cases (ObjectUtils, describeType, is, attribute “className” ), so here a function that does the job :
private static function getType(value:*):String
{
import flash.utils.*;
var description:XML = describeType(value);
return description[0].@name;
}
List based component (Tree/List/DataGrid/AdvancedDatagrid…) – selectIndex & scrollToIndex
Ok, let’s say you want to select a line in your Tree/List/DataGrid and make it visible by scrolling to it automatically.
After a quick look at the flex doc, you will just write something like that :
myTree.selectedIndex = n;
myTree.scrollToIndex(n);
But it won’t work. After selecting a new line in your list based component, you need to wait for the FlexEvent.VALUE_COMMIT event to be sure the line is selected, then you can call the scrollToIndex function.
So here an example :
myTree.addEventListener(FlexEvent.VALUE_COMMIT, onSelectedChange);
myTree.selectedIndex = n;
function onSelectedChange(event:Event):void
{
myTree.removeEventListener(FlexEvent.VALUE_COMMIT, onSelectedChange);
myTree.scrollToIndex(n);
}