Skip to main content
June 20, 2007
Question

A question about _lockroot

  • June 20, 2007
  • 1 reply
  • 226 views
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!

This topic has been closed for replies.

1 reply

Inspiring
June 20, 2007
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.
June 20, 2007
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.