2 Replies Latest reply on Jun 20, 2007 7:24 AM by utopiashi

    A question about _lockroot

    utopiashi
      The parent movie "test.fla" is empty with follow actionscript code in timeline:

      stop();
      var tc = new TestClass(); //the wanted result is "_level0"
      var myTest = _root.createEmptyMovieClip("myTestMovie", _root.getNextHighestDepth());
      myTest.loadMovie("TestChild.swf");

      ===================================
      The TestClass.as is :

      class TestClass
      {
      function TestClass()
      {
      trace("Current root is : " + _root);
      }
      }

      ===================================
      The TestChild.fla is empty with follow actionscript code in timeline:

      stop();
      this._lockroot = true;
      var tc = new TestClass(); //the wanted result is "_level0.myTestMovie"

      ===================================================
      But the result is :
      _level0
      _level0

      ===================================================
      when I change the code in test.fla into the following:
      stop();
      //var tc = new TestClass();
      var myTest = _root.createEmptyMovieClip("myTestMovie", _root.getNextHighestDepth());
      myTest.loadMovie("TestChild.swf");

      ----------------------------
      The result is correct :
      _level0.myTestMovie

      ====================================================
      Why? And how to do?
      Help me!

        • 1. Re: A question about _lockroot
          MaxManNH Level 2
          From what I am seeing of your example you are getting the right reply from your class traces. When you lock the root of a movie anything that refers to _root within the scope of that movie will come up _level0 because that is the root level of that movie. I don't think that you can get the path you are looking for with root locked. What happens if you don't lock the root.
          • 2. A question about _lockroot
            utopiashi Level 1
            quote:

            Originally posted by: MaxManNH
            From what I am seeing of your example you are getting the right reply from your class traces. When you lock the root of a movie anything that refers to _root within the scope of that movie will come up _level0 because that is the root level of that movie. I don't think that you can get the path you are looking for with root locked. What happens if you don't lock the root.


            Thank you for your help. But the "_level0" is not the right reply, the locked root is _level0.myTestMovie. In fact, when I delete the statement "var tc = new TestClass();" from test.fla, all is ok, and the result is _level0.myTestMovie.
            Please focus on the statement "var tc = new TestClass();" present to both of the fla files, It's the real reason of the problem,but I don't know why. I even think it is the bug of flash.