1 Reply Latest reply on Sep 16, 2007 10:29 PM by raghunathrao

    ..null object reference

    scrattis Level 1
      Getting this runtime error and cant get to work it out so that it wouldn't show this message. And it doesn't even show this message everytime! anyway. a hintaLaskuri -funtion is a function that I load at startup (error message shows then) and at every one second. Here is the error code and actual function:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at vaihtokaista2/::hintaLaskuri()
      at Function/ http://adobe.com/AS3/2006/builtin::apply()
      at ()
      at flash.utils::SetIntervalTimer/flash.utils:SetIntervalTimer::onTimer()
      at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
      at flash.utils::Timer/flash.utils:Timer::tick()

      -----------

      private function hintaLaskuri():void {

      var now:Date = new Date(); now.getTime()/1000;
      //Alert.show((NYT.getTime()/1000).toString());
      for (var i:int=0;i<xlAuto.length();i++) {
      if(xlAuto .Varaus[0] != 1) {

      if(xlAuto
      .LopetusPvm[0] < (now.getTime()/1000)+aikalatency) {
      var hintaMuutos:Number = 0;
      var hintaNyt:Number = xlAuto .LopetusHinta[0];
      delete xlAuto
      ;
      }
      else {
      hintaMuutos = ((xlAuto .AloitusHinta[0] - xlAuto.LopetusHinta[0]) / (xlAuto .LopetusPvm[0] - xlAuto.AloitusPvm[0])) * (((now.getTime()/1000)+aikalatency - xlAuto .AloitusPvm[0]));
      hintaNyt = xlAuto
      .AloitusHinta[0]-hintaMuutos;
      xlAuto .HintaNyt[0] = hintaNyt;
      }


      }
      }



      autotCol.refresh();

      var hintanumero:Number;
      var hintateksti:String;
      var numerot:Array;
      hintanumero = Number(autotCol.source.(Rekisteri[0] == suosituin[0]).HintaNyt);
      if(hintanumero < 10000)
      hintateksti = " " + autotCol.source.(Rekisteri[0] == suosituin[0]).HintaNyt.toString();
      else
      hintateksti = autotCol.source.(Rekisteri[0] == suosituin[0]).HintaNyt.toString();

      numerot = hintateksti.split("");
      l_1_1.text = numerot[0];
      l_1_2.text = numerot[1];
      l_1_3.text = numerot[2];
      l_1_4.text = numerot[3];
      l_1_5.text = numerot[4];
      l_1_6.text = ",";
      l_1_7.text = numerot[6];
      l_1_8.text = numerot[7];

      }
        • 1. Re: ..null object reference
          raghunathrao Level 1
          Looking at your code... there are only a couple of variables that are external to this function. xlAuto, Rekisteri & autotCol seems to be it.

          Can you check if any of them are null (by putting a breakpoint in FlexBuilder and adding these variables to the variables watch window.