Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/10/2008, 17:31
Avatar de Kravitz
Kravitz
 
Fecha de Ingreso: julio-2005
Ubicación: Edo. de México
Mensajes: 121
Antigüedad: 18 años, 9 meses
Puntos: 2
Respuesta: Comunicar entre clases DataGrid cellRenderer

Se me ocurren 2 escenarios uno: que se importe una clase denro de la otra como en java o dos: obtener el nombre de la instancia con getItemAt: culaquier informacion al respecto sera bien recibida ya qu ees el unico dilema que me falta por resolver para terminar mi proyecto gracias

btw estas son las clases si le quieren echar un lente

NumericStepperRenderer.as
Código:
import mx.core.UIComponent
import mx.controls.NumericStepper

class com.flashdb.NumericStepperRenderer extends UIComponent
{

   var step : MovieClip;
   var listOwner : MovieClip; // the reference we receive to the list
   var getCellIndex : Function; // the function we receive from the list
  // var   getDataLabel : Function; // the function we receive from the list
   
   function NumericStepperRenderer()
   {
   }

   function createChildren(Void) : Void
   {   
      //Creates a ComboBox object and listen to changes
      attachMovie("NumericStepper", "step", 1, {styleName:this, owner:this});
      step.addEventListener("change", this);
      size();
   }

   // note that setSize is implemented by UIComponent and calls size(), after setting
   // __width and __height
   
   function size(Void) : Void
   {
     // step.setSize(30, 22);
      //step._x = (__width-150)/2;
      //step._y = __height;
   
   var h = __height;
    var w = __width;      
    //  step.setSize(w - 2, Math.max(h, listOwner.rowHeight - 2));
       step.setSize(w - 2, 22);
   }

   function setValue(str:String, item:Object, sel:Boolean) : Void
   {   //Get values from the dataProvider
      //item.Model is an array of labels/data pairs
      step.visible = (item!=undefined);
      //combo.dataProvider = item.Model;
   }
/*
   function getPreferredHeight(Void) : Number
   {
      return 20;
   }

   function getPreferredWidth(Void) : Number
   {
      return 16;
   }
*/   
   function calculaFcn(cnt:Number,costo:Number)
{
	//var val = 429.00;
	var resultado:Number = cnt*costo;
	//var numero:Number = Math.round (resultado * 100) / 100;
	//this[inst].text = "$"+resultado;
trace("$"+resultado);
	//inpt.text = resultado;
	_global.res = resultado;//¿¿¿¿¿¿¿¿¿¿¿¿COMO ASIGNO EL RESAULTADO AL TEXTINPUT?????????????????????????????
	}
   
   
   function change()   
   {
      //trace("Changed");
 //  var index = getCellIndex();
//var colName = listOwner.selectedItem.getCellIndex();
//.getColumnAt(index.columnIndex).columnName;
//trace(colName); 
   var index = getCellIndex();
var colName = listOwner.getColumnAt(index.columnIndex).columnName;
trace("Nombre de la columna: "+colName);
//listOwner.dataProvider.editField(index.itemIndex, colName, someVal);
trace("no de columna: "+ index.columnIndex);
trace("no de celda: "+ index.itemIndex);
trace("cantidad: "+step.value);
   trace("Nombre de la columna 4: " + listOwner.getColumnAt(4).columnName);
   trace("Precio contenido en la columna "+ index.columnIndex + " Celda " + index.itemIndex + ": " + listOwner.getItemAt(index.itemIndex).Precio);
   
   calculaFcn(step.value, listOwner.getItemAt(index.itemIndex).Precio);
   
   }

}

TextInputRenderer.as
Código:
import mx.core.UIComponent
import mx.controls.NumericStepper

class com.flashdb.TextInputRenderer extends UIComponent
{
   var inpt : MovieClip;
   var listOwner : MovieClip; // the reference we receive to the list
   var getCellIndex : Function; // the function we receive from the list
	
	
	function TextInputRenderer()
   {
   }

  function createChildren(Void) : Void
   {   
      //Creates a ComboBox object and listen to changes
     inpt =createObject("TextInput", "inpt", 1, {styleName:this, owner:this});
     inpt.addEventListener("change", this);
      size();
   }  
   
    function size(Void) : Void
   {
     // step.setSize(30, 22);
      //step._x = (__width-150)/2;
      //step._y = __height;
   
    var h = __height;
    var w = __width;      
    //  step.setSize(w - 2, Math.max(h, listOwner.rowHeight - 2));
       inpt.setSize(w - 2, 22);
   }

function setValue(str:String, item:Object, sel:Boolean) : Void
   {   //Get values from the dataProvider
      //item.Model is an array of labels/data pairs
      inpt.visible = (item!=undefined);
      inpt.editable = false;
	  //combo.dataProvider = item.Model;
   //inpt.text = str;
   }
function change()
{
	inpt.text = _global.res;  //SE ME OCURRIA QUE AÑADIENDO UN LISTENER AL INPUT SIN EMBARGO NO SIRVE PORQUE NO ES EL INPUT EL QUE CAMBIA SINO EL NUMERIC
	}
}