1 Reply Latest reply on Jul 26, 2007 9:56 AM by lvbao

    problem calling a function on the main timeline

    lvbao
      I load an XML file on the main timeline and have a function return the values in an array
      /***************************************************************/
      function getStates(st) {
      for (i in arr_st) {
      if(arr_st == st) {
      arr_rlt = [ arr_msg
      , arr_url ];
      return arr_rlt;
      }
      }
      }
      /****************************************************/
      When calling this function from a movie clip, it works fine but I have to call the function on every event
      /***************************************************/
      on (rollOver) {
      var arr_AK:Array = _level0.getStates('AK');
      _parent.txt_msg.text = arr_AK[0];
      }

      on (press) {
      var arr_AK:Array = _level0.getStates('AK');
      if(arr_AK[1] == "")
      break;
      else
      getURL(arr_AK[1]);
      }
      /**************************************************************/
      I want to call it from a movie clip's time line (the main movie clip) so that I don't have to call the function on every event, it always give me 'undefined'

      var arr_AK:Array = _level0.getStates('AK');
      trace(arr_AK);

      What am I doing wrong here :)? Thanks in advance.
        • 1. problem calling a function on the main timeline
          lvbao Level 1
          I got it work BTW.
          I guess firstly, to call a function I need to call it on an event. Secondly, a variable with 'var' is a local variable so I can't pass it around. Here it is:

          /***************************************/
          this.onEnterFrame = function() {
          arr_ak = _level0.getStates('AK');
          arr_tx = _level0.getStates('TX');
          }
          /****************************************************/
          on the movie clip:
          /*******************************************/
          on (press) {
          if(_parent.arr_ak[1] == "")
          break;
          else
          getURL(_parent.arr_ak[1]);
          }
          on (rollOver) {
          _parent.txt_msg.text = _parent.arr_ak[0];
          }
          on (rollOut) {
          _parent.txt_msg.text = '';
          }
          /*********************************************************/
          Experts please tell me if I am doing right. Thanks in advance.