<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="init();" viewSourceURL="srcview/index.html">
<mx:Style>
Application {
verticalAlign: middle;
backgroundColor: white;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.XMLListCollection;
import mx.collections.SortField;
import mx.collections.Sort;
import flash.system.Capabilities;
private var xlc:XMLListCollection;
/**
* The "brains" of the operation. This gets called by the
* Application container's creationComplete event handler.
* This method does the E4X to grab all accessors from the
* flash.system.Capabilities class and limit the results
* to just the Capabilities class. Finally it populates the
* Label control, sorts the XMLListCollection and populates
* the DataGrid control's dataProvider property.
*/
private function init():void {
const className:String = "flash.system::Capabilities";
var capXML:XML = describeType(Capabilities);
xlc = new XMLListCollection(capXML.accessor.(@declaredBy == className));
var ver:String = Capabilities.version;
var dbg:String = (Capabilities.isDebugger) ? ' (debug)' : '';
lbl.text = ver + dbg;
var nameSort:Sort = new Sort();
nameSort.fields = [new SortField('@name', true)];
xlc.sort = nameSort;
xlc.refresh();
dataGrid.dataProvider = xlc;
}
/**
* Return the value from the Capabilites class.
*/
private function valueLabelFunc(item:Object, column:DataGridColumn):String {
return Capabilities[item.@name];
}
]]>
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Label id="lbl"
fontFamily="Arial"
fontSize="48"
fontWeight="bold"
selectable="true"
width="100%"
textAlign="center" />
</mx:ApplicationControlBar>
<mx:DataGrid id="dataGrid"
width="100%"
height="100%"
variableRowHeight="true"
editable="true"
themeColor="haloSilver">
<mx:columns>
<mx:DataGridColumn dataField="@name"
headerText="Name:"
editable="false" />
<mx:DataGridColumn labelFunction="valueLabelFunc"
headerText="Value:"
wordWrap="true">
<mx:itemEditor>
<mx:Component>
<mx:TextArea editable="false" />
</mx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>