This content has been marked as final. Show 10 replies
interesting. i've never looked at _lockroot before.
i don't know if it's the best practice, but my solution to that problem has been to set a variable within LoadVars(or any other object that doesn't extend movieclip) to this. eg..
article_news_raw = new LoadVars();
and then use that variable("owner" in the example) from then on within any event handlers to refer to "this".
Thank you both for the answers. I did read a little about lockroot but it sounded like it was a last resort/workaround which might fail in some cases.
As for the 'owner' trick... I'm not sure I understand.
I add the owner line you wrote immediately after the variable declaration right? Before the onload function?
But how do I use it within the function to access that articles_panel mc?
Replace _root with owner. (or perhaps this.owner)
Nice one. You got it. It takes 'this.owner' to work. I can't say I really understand it exactly though.
Now can you tell me if this trick is referenced in the Help file anywhere?
sorry nah not off the top of my head - although i use help all the time i don't think i've seen this technique. i have seen it other folk's code though. just today even! https://service.breezecentral.com/devnet/flashmediaserver/articles/on_demand_player_print .html
in the NetConnection object rather than the loadVariables object though.
it's basically because only movieclips and objects that extend movieclips(and buttons to an extent) have a this property that refers to it's location in the movieclip hierarchy. If you want an object such as loadVariables to know where it was defined in the hierarchy you have to tell it. (by setting a variable called 'owner' for example). You are then able to access this variable from within any event handlers for this object.
I was unaware of any _lockroot problems. Can you please direct me to the documentation that presents it as a last resort or that it is buggy? I have never had problems with it. The only problem I heard about was that the combobox component had problems with it, but that was a bug in the component.
ok here we go answers to two questions:
norrisoft - this article describes some best practices which advises against _lockroot and _root in general..
nicknameforme - i think that was the article you quoted earlier, and i think it answers your question whether "this trick is referenced in the Help file anywhere?" the same article advises you use "a pointer to the local class file so that you can directly reference the class from the onLoad handler."
Thanks Craig -- yes that's the information I was referring to re: lockroot.
I never saw that .this trick you pointed out though, because I found my info in the Help file (not the articles), and it turns out 'the trick' was listed several pages later. And quite frankly, if I had read it, I wouldn't have understood how to use it anyway. Thanks again for clearing it up.
Good info. Thanks!!