The following example shows you how you can display all the getters/setters and their current values for a Flex TextArea control by using the describeType() method, some E4X filtering, and an XMLListCollection.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/05/displaying-all-the-properties-of-a-component-instance-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
creationComplete="init();">
<mx:Script>
private var xmlDebug:XML;
private function init():void {
xmlDebug = describeType(targetObj);
xmlListColl.source = xmlDebug.accessor.(@declaredBy == xmlDebug.@name);
}
private function labelFunc(item:Object, col:DataGridColumn):String {
var value:Object = targetObj[item.@name];
if (value == null) {
return "(null)";
}
return value.toString();
}
</mx:Script>
<mx:XMLListCollection id="xmlListColl">
<mx:sort>
<mx:Sort>
<mx:fields>
<mx:SortField name="@name" />
</mx:fields>
</mx:Sort>
</mx:sort>
</mx:XMLListCollection>
<mx:VDividedBox width="100%" height="100%">
<mx:TextArea id="targetObj"
resize="init();" />
<mx:DataGrid id="dataGrid"
dataProvider="{xmlListColl}"
color="black"
width="100%"
height="100%">
<mx:columns>
<mx:DataGridColumn dataField="@access"
itemRenderer="RedLabel" />
<mx:DataGridColumn dataField="@name" />
<mx:DataGridColumn labelFunction="labelFunc"
headerText="value" />
</mx:columns>
</mx:DataGrid>
</mx:VDividedBox>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/05/displaying-all-the-properties-of-a-component-instance-in-flex/ -->
<mx:Label xmlns:mx="http://www.adobe.com/2006/mxml" color="{(data.@access == 'readonly') ? 0xFF0000 : 0x000000}" />
View source is enabled in the following example.

{ 4 comments… read them below or add one }
Hi,
Just thought that i would post a quick note saying that i wrote a similar post a short while ago about Using describeType( ) and getDefinitionByName( ) to return a Dictionary of public static const. That is also usefull.
http://www.betadesigns.co.uk/Blog/2008/06/05/using-describetype-and-getdefinitionbyname-to-return-a-dictionary-of-public-static-const/
hi !
thank you for this help ! i have a wish tu upgrade the example :
firstly, is it possible to have a different font size (so different height) in each cell by row ?
then, secondly, can we put some line return in the cell ?
This 2 features are possible in GTK with Pango, so i try to find out how to do the same in Flex3…maybe it is not possible to have some carriage return and different height by rows …..
any help ?
Yeah, it’s probably possible if you create an item renderer that displays HTML text instead of plain text (so set the
htmlTextproperty instead of thetextproperty). Try checking Alex Harui’s excellent blog at http://blogs.adobe.com/aharui/, I believe he has a couple examples of using HTML in an item renderer.Peter
here is a example of what i try to do in Flex :
http://mcclinews.free.fr/python/pygtktutfr/figures/celltextmarkupfig.png
Each line, even each word, can have a different font and size for each line in the list item !