3 Replies Latest reply on Feb 26, 2010 11:05 AM by kglad

    About lockroot and how to avoid using it


      I have a movie that's nested inside a few movies. At one point, I'm using some nested for loops to populate some ComboBox components within it. The code goes as this:


      var xmlComboBoxValues:XML = new XML();

      xmlComboBoxValues.ignoreWhite = true;


      xmlComboBoxValues.onLoad = function():Void  {

           var oComboBoxTitles:Object = xmlComboBoxValues.firstChild.childNodes;

           for (i = 0; i < oComboBoxTitles.length; i++) {

                for (j = 0; j < oComboBoxTitles[i].childNodes.length; j++) {

                     _root["cb" + i].addItem({label:oComboBoxTitles[i].childNodes[j].attributes.label, data:oComboBoxTitles[i].childNodes[j].attributes.id});





      My problem is that if I replace "_root" for "this", it doesn't work (and I don't know why; I've always had trouble with this part of using a loop to go through multiple clips).


      This movie is called by another movie via the PopUpManager class, so it isn't the _root movie in its final version. If I use "this._lockroot = true;" I can get it working through the "root" keyword (never been able to get it to work via "this", which is what I really want) - but by locking its root, does it mean that I can't pass data back and forth between the host movie and this movie because I locked it out of the true root?


      This is not a big issue at this point of the app that I'm building, but it will become a problem later on, which is why I want to know its final effect ASAP (and if I need to find a solution, and which is it).