5 Replies Latest reply on Sep 3, 2008 3:06 PM by Jale3

    putting a game inside one big movieclip

      I'm using the script below on a movie clip that moves and interacts with other movie clips. the movie clip the script is applied to is on it's own keyframe on the timeline in the main scene. now, i want to put everything i just made (the movie clip the script is applied to and the movie clips it interacts with) into one big movie clip so i can easily put it on a flash based website. I'm pretty sure the "_root." has to be changed but I'm not quite sure what to change it to
        • 1. Re: putting a game inside one big movieclip
          NSurveyor Level 2
          Jale3,

          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.
          • 2. Re: putting a game inside one big movieclip
            Level 1
            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"?
            • 3. Re: putting a game inside one big movieclip
              Level 1
              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?
              • 4. Re: putting a game inside one big movieclip
                Level 1
                (The "MC" after this._parent is a mistake made by my, and even when i take that away nothing happens
                • 5. Re: putting a game inside one big movieclip
                  Level 1
                  (The "MC" after this._parent is a mistake made by me, and even when i take that away nothing happens