0 Replies Latest reply on May 18, 2006 8:54 AM by loditferma

    Array from external file ?

    loditferma

      Ok I hope someone can help with this:

      I am trying to get variable label: and data: for a combobox. So I figured I'd have to use an Array and feed it from an external file so that i can easily add or change the content .I can't get it to work. This is what 've done so far.

      //Actionscript:

      // Load array from external file for dataprovider
      // load an external list of variables
      artists = new LoadVars();
      artists.load(" http://www.myserver.com/mytextfile.txt");
      // check to see if its finished loading
      artists.onLoad = function(success) {
      // if its finished loading, split the vars into a new array
      if (success) {
      trace ("succes");
      trace (artists);
      my_dP = artists.split(",");
      for (var i = 0;i<my_dP.length;i++){
      // trace to see how many items are in array
      trace(my_dP );}



      }
      };

      // assign to comboBox
      my_cb.dataProvider = my_dP;


      // Add event listener and event handler function.
      var cbListener bject = new Object();
      cbListener.change = function(evt_obj bject):Void {
      var currentlySelected bject = evt_obj.target.selectedItem;
      trace(evt_obj.target);
      trace("data: "+currentlySelected.data);
      trace("label: "+currentlySelected.label);
      loadVariables(currentlySelected.data,_root);

      };
      my_cb.addEventListener("change", cb Listener);

      //The Txtfile:

      &"{label:"choose..."},{data:" http://www.myserver.com/othertxtfile.txt",label:"Johannes Lauxen"},{data:" http://www.myserver.com/thirdtxtfile.txt",
      label:"PQR1"}"


      //My output returns this:

      succes
      artistTxt=%22%7Blabel%3A%22choose%2E%2E%2E%22%7D%2C%7Bdata
      %3A%22http%3A%2F%2Fwww%2Emyserver%2Ecom%2F
      anothertxtfile%2Etxt%22%2Clabel%3A%22Johannes%20Lauxen
      %22%7D%2C%7Bdata%3A%22http%3A%2F%2Fwww%2Emyserver%2E
      com%2Fthirdtxtfile%2Etxt%22%2C%20label%3A%22PQR1%22%7D%22&onLoad=%5Btype%20Function%5D


      I fear the error(s) can be anywhere. Could it simply be the txtfile formatting ?
      If anyone has any ideas, please help. Thnx in advance.
      Dilari