<?xml
version="1.0"?>
<!--
dpcontrols/DataGridPassData.mxml -->
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initData()"
backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#602121, #602121]"
layout="absolute">
<mx:Script>
<![CDATA[
import
mx.collections.*;
private var
DGArray:Array = [
{Artist:'Pavement', Album:'Slanted
and Enchanted', Price:11.99},
{Artist:'Pavement', Album:'Brighten
the Corners', Price:11.99}];
[Bindable]
public var
initDG:ArrayCollection;
//Initialize initDG
ArrayCollection variable from the Array.
//You can use this technique
to convert an HTTPService,
//WebService, or RemoteObject
result to ArrayCollection.
public function
initData():void {
initDG=new
ArrayCollection(DGArray);
}
]]>
</mx:Script>
<mx:DataGrid
id="myGrid" width="350"
height="200"
dataProvider="{initDG}" x="10"
y="58">
<mx:columns>
<mx:DataGridColumn
dataField="Album" />
<mx:DataGridColumn
dataField="Price" />
</mx:columns>
</mx:DataGrid>
<mx:Label
x="10" y="10" text="Populate
Datagrid using Arrays defined in Scripts" width="375"
height="40" color="#FFFFFF"
fontSize="15"/>
</mx:Application>
No comments:
Post a Comment