2012-01-18 4 views
0

내 플렉스 2 응용 프로그램을 실행할 때 나는 다음과 같은 런타임 오류 얻을 : 즉런타임 오류 2

TypeError: Error #1009: No se puede acceder a una propiedad o a un método de una referencia a un objeto nulo.

를, 플렉스 SDK는 나에게 말하고 나의 itemRenderer를 내부의 "파운드"변수 null입니다 (디버거로 검사했는데 그렇습니다. 실제로 null입니다). 내가 뭘 잘못하고 있니?

오류를 유발하는 행은 다음과 같습니다. lb.text = value.spe_name;

내 TileList 구성 :

<mx:TileList variableRowHeight="true" liveScrolling="false" width="100%" textAlign="left"  height="100%" columnCount="2" dataProvider="{model.specialfield_issue_list}" itemRenderer="org.nevis.cairngorm.mod.view.IRCampoEspecial" direction="horizontal"></mx:TileList> 

내 itemRenderer를 단순화 soure 코드 :

<?xml version="1.0"?> 
    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" 
     horizontalAlign="left" verticalAlign="middle" 
     verticalGap="0" borderStyle="none" width="100%" height="100%" 
    horizontalScrollPolicy="off" verticalScrollPolicy="off" toolTip="" creationPolicy="all" 
    > 

     <mx:Script> 
      <![CDATA[ 
      import mx.controls.TextArea; 
      import mx.controls.Text; 
      import org.nevis.cairngorm.mod.model.ModelLocator; 
      import mx.core.UIComponent; 
      import mx.controls.Label; 
      import mx.controls.ComboBox; 
      import mx.controls.TextInput; 
      import utils.Utils; 
      import mx.collections.ArrayCollection; 
      import mx.controls.Alert; 

      [Bindable] 
      public var model:ModelLocator=ModelLocator.getInstance(); 

      [Bindable] 
      private var fieldLabelVisible:Boolean = false; 

      [Bindable] 
      private var textInputVisible:Boolean = false; 

      [Bindable] 
      private var textAreaVisible:Boolean = false; 

      [Bindable] 
      private var comboBoxVisible:Boolean = false; 

      [Bindable] 
      private var mandatoryLabelVisible:Boolean = false; 


      public function updata_valor_text(valor:Event):void { 
       data.value=valor.currentTarget.text; 
      } 

      public function updata_valor_combo(valor:Event):void { 
       data.value=valor.currentTarget.selectedItem.valuesspecialfieldid 
      } 

      override public function set data(value:Object):void { 
       var i:int; 
       var sel:int; 

       if (value){ 

       super.data = value; 

       fieldLabelVisible = true; 
       lb.text=value.spe_name; 
       lb.toolTip=value.spe_description; 
       lb.width=150; 
       lb.name='etiqueta'; 
       lb.styleName='texto-iza'; 

       } else { 
        fieldLabelVisible = false; 
        textInputVisible = false; 
        textAreaVisible = false; 
        comboBoxVisible = false; 
        mandatoryLabelVisible = false; 
       } 
      } 

      ]]> 
     </mx:Script> 

     <mx:Label id="lb" visible="{fieldLabelVisible}" includeInLayout="{fieldLabelVisible}"/> 
     <mx:TextInput id="ti" visible="{textInputVisible}" includeInLayout="{textInputVisible}"/> 
     <mx:TextArea id="ta" visible="{textAreaVisible}" includeInLayout="{textAreaVisible}"/> 
     <mx:ComboBox id="cb" visible="{comboBoxVisible}" includeInLayout="{comboBoxVisible}"/> 
     <mx:Label id="mandatory" visible="{mandatoryLabelVisible}" includeInLayout="{mandatoryLabelVisible}"/> 
    </mx:HBox> 

잘 모르겠어요,하지만 난 내가 사용하고 SDK가 2.0 생각 .1 핫픽스 3입니다.

당신의 도움에 감사드립니다!

답변

0

나는 해결책을 찾았다. 내 코드에서 일어나는 일은 내가 mx 구성 요소 (Label, TextInput, TextArea 등)에 액세스하려고하면 아직 생성되지 않은 것입니다. 이 문제를 해결하기 위해 다음과 같이 callLater 함수를 사용했습니다.

override public function set data(value:Object):void { 
       var i:int; 
       var sel:int; 

       super.data = value; 

       callLater(function onceAllCreated():void{    

       if (value){ 

       fieldLabelVisible = true; 
       lb.text=value.spe_name; 
       lb.toolTip=value.spe_description; 
       lb.width=150; 
       lb.name='etiqueta'; 
       lb.styleName='texto-iza'; 

       } else { 
        fieldLabelVisible = false; 
        textInputVisible = false; 
        textAreaVisible = false; 
        comboBoxVisible = false; 
        mandatoryLabelVisible = false; 
       } 

       }); 
      } 

희망이 있으면 다른 사람에게 도움이됩니다.