4 Replies Latest reply on Aug 2, 2012 6:56 AM by Ned Murphy

    Loading a game inside a movieclip (AS2)



      I have a problem loading a game inside a movieclip (i´m using AS2)


      I have a main timeline with 6 buttons, and each button calls for an external SWF, wich loads inside an empty movie clip.


      Everything works ok, but when the game loads inside the movieclip, it won´t respond.

      The game SWF loads ok inside the movieclip, but it doesn´t respond to commands.


      If i execute the game.swf, it plays ok....but when loaded into the movieclip, it shows but you can´t play because the commands or buttons won´t respond.


      Is there a way to load this kind of swf inside a movieclip and make it work?.


      What i´m doing is:


      The button has this action:


      on (press) {

      loadMovie("game6.swf", "cargador");



      "Cargador" is the name i gave to the empy movieclip.


      I´ll appreciate any help i can get. Thanx a lot for your time.

        • 1. Re: Loading a game inside a movieclip (AS2)
          Ned Murphy Adobe Community Professional & MVP

          If the loaded game is using _root references in its code then that could be the problem since they could be targeting the file that loaded the game instead of the game's _root.


          What you might need to do is to set the _lockroot property of the file to be true.  Either that or do not use _root references in it.

          1 person found this helpful
          • 2. Re: Loading a game inside a movieclip (AS2)
            Ned Murphy Adobe Community Professional & MVP

            Another possibility is that the game file is loaded from a different folder than the main file and any files it loads are not being targeted properly as a result.  So if the game file loads other files this is something to consider as well.  When a Flash file is placed in an html page, it is as good as being in the same folder as that html page, so any files it loads need to be targeted accordingly... that goes for any files that embedded swf loads as well, such as your games.

            • 3. Re: Loading a game inside a movieclip (AS2)
              Haznut Level 1

              Hi Ned. Thanx for your reply.


              All the files are in the same folder, and all games are just 1 swf file (no php, xml, external .as or subfolders).


              About the other recomendation of using _lockroot... where should i place it? i have 3 frames (1, 2 and 3) with a stop action, and in another layer on frame 2, all the actionscript.

              If i place the code on the frame with all the actionscript, this should be at the beginning of the code, or can i place it at any line? Or is it easier to place it in one of the other frames where i placed the stop action?


              Thanx again for your reply.

              • 4. Re: Loading a game inside a movieclip (AS2)
                Ned Murphy Adobe Community Professional & MVP

                Setting the _lockroot property to true can be done 1) inside the swf game that you are loading (first frame would be best), or 2) can be done from the file doing the loading, but it has to be done after loading is complete, which means you need to use the MovieClipLoader class to determine when loading is complete.

                1 person found this helpful