Comunidad de diseño web y desarrollo en internet online

State en Flex

Citar            
MensajeEscrito el 25 Sep 2007 09:43 pm
Hola de nuevo

Tengo el siguiente problema
en una aplicación en Flex tengo el state base y he creado otro con nombre "Detalle"
dentro de Detalle, he agregado otros controles del tipo TEXT
txtTitulo
txtDetalle
etc

Cuando intento asignar un dato a cualquiera de esos nuevos controles, el compilador me genera un error de que el objeto no existe o es nulo
pregunta:
Tengo que poner alguna ruta en especial para poder acceder a estos controles?

saludos

Pino


P.D.
posteo parte del codigo utilizado

Esta es la primera parte y la que correspodneria al state base

Código :

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:calendario="componentes.*" 
   layout="absolute" 
   width="508" verticalAlign="top" horizontalAlign="center"  
   creationComplete="Iniciar()" >
   
   <mx:DateFormatter id="FormatoFecha" formatString="YYYY-MM-DD"/> 
   <mx:Panel id="PanelGeneral"  layout="absolute" title="Asignaciones " top="5" bottom="5" left="0" right="0">
      <mx:Label text="Sección" top="12" left="10" fontWeight="bold" id="label1"/>
      <calendario:DateChooserSpanish y="57" id="Fecha" left="10" cornerRadius="10" change="ConsultaTareas()"   toolTip="Fecha a consultar" height="160"/>
      <mx:ComboBox width="412" id="cboSeccion" top="10" right="10"   close="CargaCursos()" >
      </mx:ComboBox>
      <mx:Label x="192" text="Cursos de la Sección" top="40" fontWeight="bold" id="label2"/>
      <mx:List width="286" height="160" id="lstCursos" right="10" top="57" editable="false" cornerRadius="10" change="ConsultaTareas()" toolTip="Lista de cursos de la sección, seleccionar uno" >
      </mx:List>
      <mx:DataGrid id="datagrid"  doubleClick="Visualiza()" doubleClickEnabled="true" toolTip="Lista de asignaciones para esta fecha y curso" left="10" right="10" bottom="30" top="235">
         <mx:columns>
            <mx:DataGridColumn  visible="false" headerText="asignacion_id" width="0"  dataField="asignacion_id" />
            <mx:DataGridColumn headerText="F. Inicio"   textAlign="center" width="20" dataField="fecha_inicio" />
            <mx:DataGridColumn headerText="Título" width="60"                         dataField="titulo" />
            <mx:DataGridColumn headerText="Presentación"   width="20"                 dataField="presentacion" />
         </mx:columns>
      </mx:DataGrid>
   </mx:Panel>


Luego viene el sgte state:

Código :

   <mx:states>
      <mx:State name="Detalle"  >
         <mx:AddChild position="lastChild"  id="Hijo">
            <mx:Panel id="PanelDetalle"   layout="absolute" left="10" right="10" bottom="10" top="10" title="Asignación" borderColor="#0000A0" borderAlpha="0.3" color="#f8f8f8">
               <mx:Label x="86" text="Título" id="lblID" top="10" color="#400040"/>
               <mx:Label x="85" text="Curso" id="lblID0" top="36" color="#400040"/>
               <mx:Label x="71" text="Profesor" id="lblID1" top="65" color="#400040"/>
               <mx:Text width="308" height="20" id="txtTitulo"  top="10" right="30" text="32132" fontSize="13" color="#0000bf"/>
               <mx:Text width="308" height="20" id="txtCurso"  top="36" right="30" text="dsad" fontSize="13" color="#0000bf"/>
               <mx:Text width="308" height="20" id="txtProfesor"  top="63" right="30" text="asdasdasd" fontSize="13" color="#0000bf"/>
               <mx:HRule y="91" width="428" height="14"  right="20"/>
               <mx:Label x="20" text="Fecha Publicación" id="lblID2" bottom="347" color="#000000"/>
               <mx:Text x="130" width="75" height="20" id="txtFInicio"  bottom="348" fontSize="13" text="aaaaa" color="#0000bf"/>
               <mx:Label x="10" text="Fecha Presentación" id="lblID3" bottom="327" color="#000000"/>
               <mx:Text x="130" width="75" height="20" id="txtFLimite"  bottom="328" fontSize="13" text="aaaaa" color="#0000bf"/>
               <mx:Text width="369" height="20" id="txtTipo"  bottom="288" right="39.5" text="fsdfsfsf" color="#0000bf" fontSize="13" textAlign="center"/>
               <mx:TextArea width="369" height="206" id="txtDetalle" editable="false" wordWrap="true" bottom="74" right="39.5" shadowDistance="10" shadowDirection="left" backgroundAlpha="0.45" backgroundColor="#0000BF" color="#ffffff" text="fsdfsfsdfsdf." fontSize="13" fontWeight="bold" cornerRadius="5" borderStyle="solid" borderColor="#0000bf"/>
               <mx:Button label="Cerrar" id="cmdCerrar" bottom="10" horizontalCenter="0"   click="currentState=''"/>
               <mx:Image x="6" y="6" width="63" height="73" source="file:///S|/Gedu/Imagenes/insignia.gif" alpha="0.52"/>
            </mx:Panel>
         </mx:AddChild>
         <mx:RemoveChild target="{cboSeccion}"/>
         <mx:RemoveChild target="{lstCursos}"/>
         <mx:RemoveChild target="{Fecha}"/>
         <mx:RemoveChild target="{PanelTareas}"/>
         <mx:RemoveChild target="{label1}"/>
         <mx:RemoveChild target="{label2}"/>
      </mx:State>
   </mx:states>




Finalmente la parte de mi codigo donde intento acceder a las propiedades en cuestion

Código :

      private function detalletarea_Result(event:ResultEvent):void
      {
            var Formato:DateFormatter ; 
            resultado = new ArrayCollection(event.result as Array);
         if(resultado != null)
         {
            if(resultado[0])
            {
               txtTitulo.text = resultado[0][9];
               txtProfesor.text = resultado[0][15].toString() ;   
               txtCurso.text = resultado[0][14].toString() ;      
               txtTipo.text = resultado[0][17].toString()      ;
               txtDetalle.text = resultado[0]["descripcion"].toString();
                                        currentState = "Detalle";

            }
         }

      }


gracias de antemano x la ayuda.

Por pinocho

78 de clabLevel



Genero:Masculino  

Luna City

firefox
Citar            
MensajeEscrito el 25 Sep 2007 10:06 pm
Sigo respondiendo mis dudas :)

la falta idiota que tenia (no me queda otro calificativo para mi forma de evaluar los problemas)
era que:
el currentState =" Detalle" deberia ir antes de la manipulacion de sus componentes !!
es decir

si quiero manipular los componentes de un state, primero debo seleccionarlo o ponerlo como activo :)
mi funcion debio ser asi (y ya funciona):

if(resultado[0])
{
currentState = "Detalle";
txtTitulo.text = resultado[0][9];
txtProfesor.text = resultado[0][15].toString() ;
txtCurso.text = resultado[0][14].toString() ;
txtTipo.text = resultado[0][17].toString() ;
txtDetalle.text = resultado[0]["descripcion"].toString();
....

Por pinocho

78 de clabLevel



Genero:Masculino  

Luna City

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.