BUeno no se si estamos a tiempo pero aqui va lo unico que no he logrado es obtener los datos del checkbox estoy trabajando en eso si logras algo avisame
El Fla:
import fl.controls.DataGrid;
import fl.data.DataProvider;
import fl.controls.Button;
import fl.controls.TextInput;
import fl.controls.dataGridClasses.DataGridColumn;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.*;
import flash.text.TextField;
import CustomCheckBoxCellEditor;
var dg:DataGrid = new DataGrid();
var c1:DataGridColumn = new DataGridColumn("Id");
var c2:DataGridColumn = new DataGridColumn("Nic");
var c3:DataGridColumn = new DataGridColumn("NoCliente");
var c4:DataGridColumn = new DataGridColumn("Poliza");
var c5:DataGridColumn = new DataGridColumn("Nombre");
var c6:DataGridColumn = new DataGridColumn("Procesar");
dg.addColumn(c1);
dg.addColumn(c2);
dg.addColumn(c3);
dg.addColumn(c4);
dg.addColumn(c5);
dg.addColumn(c6);
dg.getColumnAt(5).cellRenderer= CustomCheckBoxCellRenderer;
dg.getColumnAt(5).itemEditor = CustomCheckBoxCellEditor;
dg.setSize(600,300);
//dg.move(20,20);
dg.y=250;
dg.x=60;
dg.editable = true;
addChild(dg);
var xml:XML;
var url:URLRequest=new URLRequest("mostrar.php");
var loader:URLLoader=new URLLoader();
loader.load(url);
function Cargar(event):void {
var xml:XML=new XML(loader.data);
var dp:DataProvider=new DataProvider(xml);
dg.dataProvider = dp;
}
loader.addEventListener(Event.COMPLETE, Cargar);
function sel(event):void{
if(dg.selectedItem.data == "true"){
prueba.text = " True";
}else{
prueba.text = "Falso";}
}
dg.addEventListener(Event.CHANGE, sel);
function Elegir(e:MouseEvent):void {
var link:String = new String();
link = dg.selectedItem.Id;
var php:String = "insertar.php";
var req:URLRequest = new URLRequest(php);
var vars:URLVariables = new URLVariables();
req.method = URLRequestMethod.POST;
req.data = vars;
vars.chec = link;
navigateToURL(req);
}
dg.addEventListener(MouseEvent.DOUBLE_CLICK, Elegir);
LA PRIMER CLASE:
package
{
import fl.controls.ButtonLabelPlacement;
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.controls.listClasses.ListData;
import fl.controls.listClasses.ICellRenderer;
import fl.controls.LabelButton;
import fl.core.UIComponent;
import flash.events.Event;
import flash.events.MouseEvent;
import fl.controls.CheckBox;
import fl.controls.listClasses.CellRenderer;
import flash.display.DisplayObject;
[Style(name="icon", type="Class")]
[Style(name="upIcon", type="Class")]
[Style(name="downIcon", type="Class")]
[Style(name="overIcon", type="Class")]
[Style(name="disabledIcon", type="Class")]
[Style(name="selectedDisabledIcon", type="Class")]
[Style(name="selectedUpIcon", type="Class")]
[Style(name="selectedDownIcon", type="Class")]
[Style(name="selectedOverIcon", type="Class")]
[Style(name="upSkin", type="Class")]
[Style(name="downSkin", type="Class")]
[Style(name="overSkin", type="Class")]
[Style(name="disabledSkin", type="Class")]
[Style(name="selectedDisabledSkin", type="Class")]
[Style(name="selectedUpSkin", type="Class")]
[Style(name="selectedDownSkin", type="Class")]
[Style(name="selectedOverSkin", type="Class")]
[Style(name="textFormat", type="flash.text.TextFormat")]
[Style(name="disabledTextFormat", type="flash.text.TextFormat")]
[Style(name="textPadding", type="Number", format="Length")]
public class CustomCheckBoxCellRenderer extends CheckBox implements ICellRenderer {
protected var _listData:ListData;
protected var _data:Object;
protected var _rowSelected:Boolean;
protected var _showLabel:Boolean = false; // Change this to true if you want the label to be shown
public function CustomCheckBoxCellRenderer():void {
super();
focusEnabled = false;
}
private static var defaultStyles:Object = { icon:null,
upIcon:"CheckBox_upIcon",downIcon:"CheckBox_downIcon",overIcon:"CheckBox_overIcon",
disabledIcon:"CheckBox_disabledIcon",
selectedDisabledIcon:"CheckBox_selectedDisabledIcon",
focusRectSkin:null,
focusRectPadding:null,
selectedUpIcon:"CheckBox_selectedUpIcon",selectedDownIcon:"CheckBox_selectedDownIcon",selectedOverIcon:"CheckBox_selectedOverIcon",
upSkin:"CellRenderer_upSkin",downSkin:"CellRenderer_downSkin",overSkin:"CellRenderer_overSkin",
disabledSkin:"CellRenderer_disabledSkin",
selectedDisabledSkin:"CellRenderer_selectedDisabledSkin",
selectedUpSkin:"CellRenderer_selectedUpSkin",selectedDownSkin:"CellRenderer_selectedDownSkin",selectedOverSkin:"CellRenderer_selectedOverSkin",
textFormat:null,
disabledTextFormat:null,
embedFonts:null,
textPadding:5 };
public static function getStyleDefinition():Object { return defaultStyles; }
override public function setSize(width:Number,height:Number):void {
super.setSize(width, height);
}
public function get listData():ListData {
return _listData;
}
public function set listData(value:ListData):void {
_listData = value;
label = (_showLabel)? _listData.label : "";
setStyle("icon", _listData.icon);
}
public function get data():Object {
return _data;
}
public function set data(value:Object):void {
_data = value;
}
override public function get selected():Boolean {
return super.selected;
}
override public function set selected(value:Boolean):void {
// Get the name of the field in the data provider item associated with
// the column being rendered
var item_dg:DataGrid = this.parent.parent.parent as DataGrid;
var field_str:String = item_dg.getColumnAt(_listData.column).dataField;
// Make sure the proper boolean value is set
(_data[field_str]=="true" || _data[field_str]==1 || _data[field_str]==true)?
super.selected=true : super.selected=false;
_rowSelected = value;
}
override protected function toggleSelected(event:MouseEvent):void {
// don't set selected or dispatch change event.
}
override protected function drawLayout():void {
var textPadding:Number = Number(getStyleValue("textPadding"));
var textFieldX:Number = 0;
// Align icon
if (icon != null) {
icon.x = textPadding;
icon.y = Math.round((height-icon.height)>>1);
textFieldX = icon.width + textPadding;
}
// Align text
if (label.length > 0) {
textField.visible = true;
var textWidth:Number = Math.max(0, width - textFieldX - textPadding*2);
textField.width = textWidth;
textField.height = textField.textHeight + 4;
textField.x = textFieldX + textPadding
textField.y = Math.round((height-textField.height)>>1);
} else {
textField.visible = false;
}
// Size background
background.width = width;
background.height = height;
}
override protected function drawBackground():void{
var styleName:String = (enabled) ? mouseState : "disabled";
if (_rowSelected) {
styleName = "selected"+styleName.substr(0,1).toUpperCase()+styleName.substr(1);
}
styleName += "Skin";
var bg:DisplayObject = background;
background = getDisplayObjectInstance(getStyleValue(styleName));
addChildAt(background, 0);
if (bg != null && bg != background) { removeChild(bg); }
}
}
}
LA SEGUNDA CLASE:
package
{
import fl.controls.ButtonLabelPlacement;
import fl.controls.CheckBox;
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
import fl.controls.LabelButton;
import fl.controls.listClasses.CellRenderer;
import fl.controls.listClasses.ListData;
import fl.controls.listClasses.ICellRenderer;
import fl.core.InvalidationType;
import fl.core.UIComponent;
import fl.data.DataProvider;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.system.IME;
[Style(name="icon", type="Class")]
[Style(name="upIcon", type="Class")]
[Style(name="downIcon", type="Class")]
[Style(name="overIcon", type="Class")]
[Style(name="disabledIcon", type="Class")]
[Style(name="selectedDisabledIcon", type="Class")]
[Style(name="selectedUpIcon", type="Class")]
[Style(name="selectedDownIcon", type="Class")]
[Style(name="selectedOverIcon", type="Class")]
[Style(name="upSkin", type="Class")]
[Style(name="downSkin", type="Class")]
[Style(name="overSkin", type="Class")]
[Style(name="disabledSkin", type="Class")]
[Style(name="selectedDisabledSkin", type="Class")]
[Style(name="selectedUpSkin", type="Class")]
[Style(name="selectedDownSkin", type="Class")]
[Style(name="selectedOverSkin", type="Class")]
[Style(name="textFormat", type="flash.text.TextFormat")]
[Style(name="disabledTextFormat", type="flash.text.TextFormat")]
[Style(name="textPadding", type="Number", format="Length", align="Center")]
public class CustomCheckBoxCellEditor extends CheckBox implements ICellRenderer {
public var text:String;
protected var _listData:ListData;
protected var _data:Object;
protected var _rowSelected:Boolean = true;
protected var _showLabel:Boolean = false;
protected var item_dg:DataGrid;
public function CustomCheckBoxCellEditor():void {
super();
focusEnabled = true;
}
private static var defaultStyles:Object = { icon:null,
upIcon:"CheckBox_upIcon",downIcon:"CheckBox_downIcon",overIcon:"CheckBox_overIcon",
disabledIcon:"CheckBox_disabledIcon",
selectedDisabledIcon:"CheckBox_selectedDisabledIcon",
focusRectSkin:null,
focusRectPadding:null,
selectedUpIcon:"CheckBox_selectedUpIcon",selectedDownIcon:"CheckBox_selectedDownIcon",selectedOverIcon:"CheckBox_selectedOverIcon",
upSkin:"CellRenderer_upSkin",downSkin:"CellRenderer_downSkin",overSkin:"CellRenderer_overSkin",
disabledSkin:"CellRenderer_disabledSkin",
selectedDisabledSkin:"CellRenderer_selectedDisabledSkin",
selectedUpSkin:"CellRenderer_selectedUpSkin",selectedDownSkin:"CellRenderer_selectedDownSkin",selectedOverSkin:"CellRenderer_selectedOverSkin",
textFormat:null,
disabledTextFormat:null,
embedFonts:null,
textPadding:5 };
public static function getStyleDefinition():Object { return defaultStyles; }
override public function setSize(width:Number,height:Number):void {
super.setSize(width, height);
}
public function get listData():ListData {
return _listData;
}
public function set listData(value:ListData):void {
_listData = value;
text = _listData.label;
label = (_showLabel)? _listData.label : "";
setStyle("icon", _listData.icon);
}
public function get data():Object {
return _data;
}
public function set data(value:Object):void {
_data = value;
swapValue();
drawNow();
}
public function get imeMode():String {
return _imeMode;
}
public function set imeMode(value:String):void {
_imeMode = value;
}
override public function get selected():Boolean {
return super.selected;
}
override public function set selected(value:Boolean):void {
swapValue();
_rowSelected = value;
}
public function swapValue():void {
var newValue:Boolean;
// Get the name of the field in the data provider item associated with
// the column being rendered
item_dg = this.parent.parent.parent as DataGrid;
var field_str:String = item_dg.getColumnAt(_listData.column).dataField;
// Make sure the proper boolean value is set
(_data[field_str]=="true" || _data[field_str]==1 || _data[field_str]==true)?
newValue = false : newValue = true;
// Update CellRenderer's appropriate values
super.selected = newValue; // Status of the CheckBox
text = String(newValue); // text property required to act as a DataGridCellEditor
// The ListData object that handles the properties applied to the cell
_listData = new ListData(String(newValue),
_listData.icon,
_listData.owner,
_listData.index,
_listData.row,
_listData.column);
// The DataGrid.dataProvider's item associated to the cell
item_dg.editField(_listData.row, field_str,newValue);
}
override protected function toggleSelected(event:MouseEvent):void {
// don't set selected or dispatch change event.
swapValue();
// Initiate an immediate draw operation
drawNow();
}
override protected function drawLayout():void {
var textPadding:Number = Number(getStyleValue("textPadding"));
var textFieldX:Number = 0;
// Align icon
if (icon != null) {
icon.x = textPadding;
icon.y = Math.round((height-icon.height)>>1);
textFieldX = icon.width + textPadding;
}
// Align text
if (label.length > 0) {
textField.visible = true;
var textWidth:Number = Math.max(0, width - textFieldX - textPadding*2);
textField.width = textWidth;
textField.height = textField.textHeight + 4;
textField.x = textFieldX + textPadding
textField.y = Math.round((height-textField.height)>>1);
} else {
textField.visible = false;
}
// Size background
background.width = width;
background.height = height;
}
override protected function drawBackground():void{
var styleName:String = (enabled) ? mouseState : "disabled";
if (_rowSelected) {
styleName = "selected"+styleName.substr(0,1).toUpperCase()+styleName.substr(1);
}
styleName += "Skin";
var bg:DisplayObject = background;
background = getDisplayObjectInstance(getStyleValue(styleName));
addChildAt(background, 0);
if (bg != null && bg != background) { removeChild(bg); }
}
}
}
espero te sirva solo tienes que poner los archivos de las clases en la misma carpeta que el fla y asi andara, obviamente debes hacer algunos cambios con respecto a tu datagrid y a tu archivo PHP.
Saludos y no dides en Preguntar