1 Reply Latest reply on Apr 28, 2006 12:23 AM by Newsgroup_User

    IF statement evaluate correctly the 2nd time????????

    Level 7
      Hi Guys!,
      The problem is this, I need to load my_array with data from an ASP, but the
      else statement runs twice, this means the trace action runs twice, when it
      shouldn,t because the second time my_array should be defined (NOTE: there IS
      data in my_array, checked).

      I also tried separated IF statemnts, the first checks the variable to be
      loaded and a second to check if the array was executed ones, didn't work.

      It seems that it need two loops to catch that my_array was defined.

      onClipEvent(enterFrame){

      if(_global.my_lv.loaded <> false && my_array == undefined) {

      var my_array:Array = _global.my_lv.vDescripcion.split("|");

      for (var i = 0; i<my_array.length; i++) {

      trace(my_array );
      }

      }

      }

      Thanks in advance,
      Eric


        • 1. Re: IF statement evaluate correctly the 2nd time????????
          Level 7
          Hi Eric,

          You would be MUCH better off using the "onLoad" event handler of your
          loadvars object:
          1) you would be guaranteed that it would run only once
          2) You wouldn't have a dummy enterframe handler laying around eating your
          CPU cycles for nothing.

          Check your actionscript dictionnary for more details.

          Tim.


          Eric Arean wrote:

          > Hi Guys!,
          > The problem is this, I need to load my_array with data from an ASP, but
          > the else statement runs twice, this means the trace action runs twice,
          > when it shouldn,t because the second time my_array should be defined
          > (NOTE: there IS data in my_array, checked).
          >
          > I also tried separated IF statemnts, the first checks the variable to be
          > loaded and a second to check if the array was executed ones, didn't work.
          >
          > It seems that it need two loops to catch that my_array was defined.
          >
          > onClipEvent(enterFrame){
          >
          > if(_global.my_lv.loaded <> false && my_array == undefined) {
          >
          > var my_array:Array = _global.my_lv.vDescripcion.split("|");
          >
          > for (var i = 0; i<my_array.length; i++) {
          >
          > trace(my_array );
          > }
          >
          > }
          >
          > }
          >
          > Thanks in advance,
          > Eric