4 Replies Latest reply on Apr 1, 2007 7:40 AM by MotionMaker

    onLoad, scope, and delegate

      This has been addressed many times as I've searched though posts and threads online, but I still can't get this to work. I'm trying to populate an array that in the class's scope with values taken from a text file. Using delegate I'm able to get out of the onLoad scope and access the array in the class's scope. This leaves me unable to reference the variables taken from the text file.

      I've looked at this webpage http://www.kirupa.com/web/xml/XMLspecificIssues3.htm. It says in the second to the last paragraph "Of course, you can also see that because the scope of the onLoad method is no longer within the XML instance and this represents the class, _xml has to be used in order to access content of the XML instance and what had been loaded." I've tried that my debug tells me there is no property someVariable nor menu_text.someVariable.

      class Container extends MovieClip
      var menu_items_array:Array = [];
      public var test:String = "Class - test variable is working!";

      public function Container()
      var menu_text = new LoadVars();
      menu_text.onLoad = Delegate.create(this, populate_menu);

      public function populate_menu()
      menu_items_array.push(menu_text.someVariable); //trying to get this to work
      trace(test); //this works
      trace(someVariable); //this doesn't work
      trace(menu_text.someVariable); //this doesn't work either


      I know this is an old problem. I just don't know the answer. Please help! Many, many thanks!