erickfm8 22 de out. de 2011
coloca todo o codigo que vc fez aii
CristianPalmaSola10 22 de out. de 2011
& lt ; fx : Script & gt ;
& lt ; ! [ CDATA [
import mx.collections.ArrayCollection ;
import mx.controls.Alert ;
import mx.collections.ArrayList ;
import mx.controls.List ;
[ Bindable ]
public var numColunas : Object = 3 ;
[ Bindable ]
public var numLinhas : Object = 3 ;
[ Bindable ]
public var valores : ArrayCollection = new ArrayCollection ([
{ col1 : 0.0 , col2 : 0.0 , col3 : 0.0 },
{ col1 : 0.0 , col2 : 0.0 , col3 : 0.0 },
{ col1 : 0.0 , col2 : 0.0 , col3 : 0.0 }]);
public function gerarValores () : void
{
}
public function gerarColunasLinhasGrid () : void
{
var array : Array = new Array ();
var _col : int = int ( numColunas );
gerarValores ();
for ( var i : int = 1 ; i & gt ; & lt ; = _col ; i ++ )
{
var coluna : DataGridColumn = new DataGridColumn ();
coluna . headerText = "col" + i ;
coluna . dataField = coluna . headerText ;
array . push ( coluna );
}
grid1 . columns = array ;
}
public function exibeValores () : void
{
var s : String = new String ();
for ( var i : int = 0 ; i & lt ; valores . length ; i ++ )
{
for ( var r : int = 0 ; r & lt ; grid1 . columns . length ; r ++ )
{
if ( valores . getItemAt ( i ) . col + r == null )
{
s += "@" ;
}
else
{
s += valores . getItemAt ( i ) . col + r + " " ;
}
}
s += " \n " ;
}
Alert . show ( s );
}
]] & gt ;
& lt ; / fx : Script & gt ;
& lt ; mx : Canvas width = "100%" height = "100%" & gt ;
& lt ; mx : VBox height = "100%" width = "60%" textAlign = "center" verticalAlign = "middle" & gt ;
& lt ; mx : Canvas width = "100%" height = "20%" & gt ;
& lt ; mx : Form width = "100%" height = "20%" & gt ;
& lt ; mx : FormItem label = "Numero Colunas.:" required = "true" & gt ;
& lt ; s : TextInput text = "@ {numColunas} " /& gt ;
& lt ; / mx : FormItem & gt ;
& lt ; mx : FormItem label = "Numero Linhas.:" required = "true" & gt ;
& lt ; s : TextInput text = "@ {numLinhas} " /& gt ;
& lt ; / mx : FormItem & gt ;
& lt ; s : Button label = "Atualizar Tela" width = "250" styleName = "botao" click = "{gerarColunasLinhasGrid()}" /& gt ;
& lt ; / mx : Form & gt ;
& lt ; / mx : Canvas & gt ;
& lt ; mx : Canvas width = "100%" height = "40%" & gt ;
& lt ; mx : DataGrid id = "grid1" width = "100%" height = "100%" editable = "true" dataProvider = " {valores} " & gt ;
& lt ; mx : columns & gt ;
& lt ; mx : DataGridColumn headerText = "Col1" dataField = "col1" /& gt ;
& lt ; mx : DataGridColumn headerText = "Col2" dataField = "col2" /& gt ;
& lt ; mx : DataGridColumn headerText = "Col3" dataField = "col3" /& gt ;
& lt ; / mx : columns & gt ;
& lt ; / mx : DataGrid & gt ;
& lt ; / mx : Canvas & gt ;
& lt ; s : Button label = "Exibir Valores" click = "exibeValores()" /& gt ;
& lt ; / mx : VBox & gt ;
& lt ; / mx : Canvas & gt ;
& lt ; / s : Application & gt ;