1 Reply Latest reply on Jun 21, 2009 11:18 PM by t@c05ru13

    commas inside array/local vs server encoding

    t@c05ru13

      Sorry if this doesn't make sense, but I'll try to be as clear as I can.

       

      I have a large flashvars string that I'm splitting into a 2d Array when it's pulled in flash. The problem I'm having is that one of the items of the inner array needs to be able to contain commas. The commas are encoded using php urlencode. I took the entire string printed on the web page and put it in a local var so I could test locally (by that i just mean without having to upload it to the server). So locally everything works fine, but when I upload it and use the real flashvars data, anything containing a comma and anything after that item, comes back as undefined.

       

      Here's an example of what part of the string in flashvars looks like. It would represent one item in the outer array.

       

      "15;nameofstore;nameofstore;C32;;nameofstore%2C+Inc.+is+the+nation%27s+largest+

      department+store+company+and+strives+to+be+the+department+store+of+choice+in+

      each+community+it+serves+by+providing+superior+service+and+merchandise+that+

      meets+customers%27+needs+for+fashion%2C+value+and+quality.;nameofstore.jpg"

       

      I loop through the outer array and convert each of it's items to a new array and add it to an outer array, like this.

      // storesarray is the flashvar

      var storesinfo:Array = storesarray.split(",");

      // storesinfos.store.id, name, slug, mapref, shortdescr
      for (var row in storesinfo) {// go through each item in parant array   
          var rowarray:Array = storesinfo[row].split(";");// split each item into its own array
          rowarray.pop();// remove last element, it's trash
          storesArray.push(rowarray);
      }

       

      this creates the array from the example above:

      15,nameofstore,nameofstore,C32,,nameofstore%2C+Inc.+is+the+nation%27s+

      largest+department+store+company+and+strives+to+be+the+department+store+

      of+choice+in+each+community+it+serves+by+providing+superior+service+and+

      merchandise+that+meets+customers%27+needs+for+fashion%2C+value+and+

      quality.,nameofstore.jpg

       

      I create objects for each outer item containing each inner item like this.

       

      var outerArraylength = storesArray.length;

      for (var i = 0; i<outerArraylength; i++) {
              // look for mapref, if no mapref, then next item in storesarray
              if (storesArray[i][3] != "") {
                  var objmapref = String(storesArray[i][3]);

                  this[objmapref] = new Object();

                  _root[objmapref].pid = storesArray[i][0];
                  _root[objmapref].pnick = storesArray[i][1];
                  _root[objmapref].pslug = storesArray[i][2];
                  _root[objmapref].pmapref = storesArray[i][3];
                  _root[objmapref].pmapgroup = storesArray[i][4];
                  _root[objmapref].pshortdescr = String(storesArray[i][5]);
                  _root[objmapref].pthumb =  storesArray[i][6];

              }
      }

       

      So now I can set text for each store by calling:

       

      _root.infobubble.storename.text = _root[themc].pnick;

       

      This works fine, if there's no comma contained in the name, but if it does, it will break. You can see the commas are encoded as "%2C".

      I've tried looping through the inner array before making the objects and converting it's items to their escaped values and strings as well as the same when I made the objects, but the comma always breaks it.

       

      Can anyone provide any insight to fixing this? Seems like if there was a way to make split(); enclose items in quotes, it would make this a non-issue.

       

      thanks