1 Reply Latest reply on Aug 3, 2006 12:27 AM by Nimi_M

    loadVariablesnum in flash

      Hi All,

      I am seeking your help to do a certain thing. As i am not well versed in action scripting i need help.

      I have written a parser to read a xml file. This xml file is being generated on runtime in .net. And i am keeping it in config folder.
      Now i am loading this flash i am loadin this xml using .load method..load method takes url (path) of that file say abc.xml.

      As the file is being generated on localhost server ;server name mite change in future so i don't want to hardcode the path of the file. Means i don't want to write

      xmlData3.load(" http://localhost/solutionname/config/BurnMiles.xml");

      rather i want to use loadvariablesnum method
      there i want to write

      then i want to use this variable so that user can change this path in future.

      i am writing the code
      but its not taking path.
      it says URL undefined.
      Please help.
      how can i do this?

      var uri=_level.URL;
      var xmlData3 = new XML();
      xmlData3.ignoreWhite = true;
      xmlData3.onLoad = processxmlData3;
      var burnorigin_array:Array = new Array();
      var totalnodes2_num:Number = 0;
      function processxmlData3(sucess:Boolean) {
      //trace("the length"+xmlData3.firstChild.childNodes.length);
      for (var k = 0; k<xmlData3.firstChild.childNodes.length; k++) {
      totalnodes2_num += xmlData3.firstChild.childNodes[k].childNodes.length;
      //trace("==> "+totalnodes2_num);
      for (var k = 0; k<totalnodes2_num; k++) {
      burnorigin_array[k] = {OriginId:"", DestinationId:"", Burnmiles:""};
      for (var i = 0,k = 0; i<xmlData3.firstChild.childNodes.length; i++) {
      for (attr in xmlData3.firstChild.childNodes .attributes) {
      //trace(attr+" = "+xmlData3.firstChild.childNodes
      //trace(xmlData3.firstChild.childNodes .childNodes.length);
      for(var j = 0; j<xmlData3.firstChild.childNodes
      .childNodes.length; j++,k++) {
      for(attr1 in xmlData3.firstChild.childNodes .childNodes[j].attributes) {
      //trace(attr1+" = "+xmlData3.firstChild.childNodes
      burnorigin_array[k][attr] = xmlData3.firstChild.childNodes .attributes[attr];
      burnorigin_array[k][attr1] = xmlData3.firstChild.childNodes
      //trace("origin array "+burnorigin_array [attr1]);
      for (var i = 0; i<burnorigin_array.length; i++) {
      trace("B OriginId: "+burnorigin_array
      .OriginId+" DestinationId: "+burnorigin_array .DestinationId+" Burnmiles: "+burnorigin_array.Burnmiles);
      var xmlData4 = new XML();
      xmlData4.ignoreWhite = true;
      xmlData4.onLoad = processxmlData4;
      var burntierZone_array:Array = new Array();
      var totalnodes3_num:Number = 0;
      function processxmlData4(sucess:Boolean) {
      for (var k = 0; k<xmlData4.firstChild.childNodes.length; k++) {
      totalnodes3_num += xmlData4.firstChild.childNodes[k].childNodes.length;
      trace("==> "+totalnodes2_num);
      for (var k = 0; k<totalnodes3_num; k++) {
      burntierZone_array[k] = {Tierid:"", Zoneid:"", BonusFraction:""};
      for (var i = 0,k = 0; i<xmlData4.firstChild.childNodes.length; i++) {
      for (attr in xmlData4.firstChild.childNodes .attributes) {
      trace(attr+" = "+xmlData4.childNodes
      trace(xmlData4.childNodes .childNodes.length);
      for (var j = 0; j<xmlData4.firstChild.childNodes
      .childNodes.length; j++,k++) {
      for (attr1 in xmlData4.firstChild.childNodes .childNodes[j].attributes) {
      //trace(attr1+" = "+xmlData4.childNodes
      burntierZone_array[k][attr] = xmlData4.firstChild.childNodes .attributes[attr];
      burntierZone_array[k][attr1] = xmlData4.firstChild.childNodes
      //trace("origin array "+burnorigin_array [attr1]);
      for (var i = 0; i<burntierZone_array.length; i++) {
      //trace("Tierid: "+burntierZone_array
      .Tierid+" Zoneid: "+burntierZone_array .Zoneid+" BonusFraction: "+burntierZone_array.BonusFraction);

        • 1. Re: loadVariablesnum in flash
          Your URL.txt should be

          What is happening is that it takes sometime for the tx file to load, and you are accessing the variable before the file is loaded.
          Try this simple test
          Call for loadVariablesNum in the first frame trace _level.URL if the fifth frame.

          You can use setInterval to check if the file has loaded.