2012-01-18 10 views
0

私はFlex 2のアプリケーションを実行すると、私は、次のランタイムエラーを取得:つまりランタイムエラー2

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

を、FlexのSDKには、私に言っていることに私たItemRenderer内部の「ポンド」変数(私はデバッガでチェックし、はい、それは本当に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; 
       } 

       }); 
      } 

希望は、これは他の誰かに役立ちます!