8 Replies Latest reply on Jun 19, 2007 8:50 AM by kglad

    Passing variable outside of a function block

    akiva.kent Level 1
      1. I have already read the Adobe docs and a gazillion Flash forums about the scope of variables within a function block. This is driving me mad!

      2. I am using a function to assign values from a parsed XML file to variables within the function block. I am successful at parsing the XML file and displaying the variables from within the function block. However, they expire outside of the function block.

      3. I would like these assigned values available globally outside of the function block.

      The pseudo code:


      function init () {

      //parse script here
      //assign parsed field values from xml file to variables - fields come from ChildNodes in the XML file - this ISN'T the issue here - the fields are parsed correctly!)
      Variable1 = field1;
      Variable2 = field2;
      Variable3 = field3;
      _global.newVariable1 = Variable1;
      _global.newVariable2 = Variable2;
      _global.newVariable3 = Variable3;


      var my_xml = new XML ();
      my_xml.onLoad = init;
      my_xml.ignoreWhite = "true";

      trace(_global.newVariable1) should NOT be "undefined" but have the value of Variable1 (the XML field value)