Bypass lockroot?

Is it possible to bypass [COLOR=“DarkOrange”]this.lockroot = true;[/COLOR] for just one function?

And make sure it stays lock for the rest of the code…

Set this.lockroot = false; before/when you start your function, then reset it to true when you exit the function.

Thanks,

so…


//on my main timeline, frame 1

this.lockroot = true;

function accessroot() {
	this.lockroot = false;
//the rest of the function goes here
this.lockroot = true;
}

is it this simple?

hey why didn’t anyone tell me that :stuck_out_tongue:

I still haven’t tested it yet…
But from Glosrfc’s comment, it seems the case.

I will make a quick movie to test it and make sure it really is that easy.

Well…

it doesn’t work!

I’m attaching my test file. Maybe I am not doing it correctly.

Files are in the wrong format.

The first question has to be…why are you addressing _root in the first place? Using absolute targets like _root is certain to cause problems and _lockroot=true is just a temporary workaround. So temporary that it was removed from AS3.

You should really be using relative addresses in the SWF you’re loading, e.g. this or _parent, or combining them this._parent where this is the loaded SWF code and _parent is the SWF into which it is loaded.

Well, I have to agree that it is far from being a convenient technique and I tried to avoid it myself. In this case, I was using a pretty heavy code that I haven’t write… and prefered not to mess with it. I could always replace all instances of _root with the proper path or using parents as you suggested.

Anyway, just wanted to see if it was possible… as it would make sense to turn off a lockroot for just a function or too. I’m pretty sure many have tried it before.

thanks for clarifying

It’s possible to turn it off using false. Another option would be to explicitly declare _level0 inside the function in which you don’t want lockroot to be true. Also note that it’s _lockroot and not lockroot, e.g.
this._lockroot = false;