This content has been marked as final. Show 5 replies
You are absolutely correct. _root refers to the main timeline of a movie. By restructuring your timeline, many of the paths no longer refer to actual MovieClips. There are a few ways of fixing this.
1. Using an absolute path again. If you give the "one big movieclip" an instance name of "big_mc", you would change all the _root's to _root.big_mc. However, this method is not recommended as it is what caused the problem in the first place.
2. Using a relative path. Clearly, the MovieClip with the above code will always be on the same timeline, with the wall and win MovieClips as well. And so, if this clip "looks" for the others from its point of view, then there should never really be a problem where you place the game. In this case, you could replace _root with this._parent. "this" simply refers to the current timeline (of the MovieClip that the code resides on) and "_parent" refers to the parent timeline from the specific MovieClip.
3. A third, lazier option would be to make all references of _root refer to the "big movieclip" and this can be achieved with one line:
big_mc._lockroot = true;
Despite being the easies fix, the second method is a better approach as there might be complications of some sort down the line.
By the way, you might want to look into the onEnterFrame event handler as a replacement for the outdated onClipEvent.
I tried the this._parent tactic before but that didn't turn up any results. So i figured I'd try the 3rd (lazy) option. Sorry, but where exactly do I need to put "big_mc._lockroot = true"?
I've tried this._parent with the buttons and they work once everything is in one movie clip and that works fine. the code for the buttons is below. But when i tried to replace all "_root" to "this._parent" on the main movie clip that moves and nothing happens. it moves fine with the arrow keys but it doesn't do onything when it touches the 'wall", nor when it touches the "win". What can anyone make of it?
(The "MC" after this._parent is a mistake made by my, and even when i take that away nothing happens
(The "MC" after this._parent is a mistake made by me, and even when i take that away nothing happens