7 Replies Latest reply on Dec 12, 2016 5:53 AM by Q4T

    If not a document class, then what?

    Q4T Level 1

      I started creating a game, and did a lot of work regarding handling of player controls in the document class. Now, I added a scene and a menu. Menu navigation requires a completely different control scheme, and my old script keeps calling useless functions that just waste processor time at best, or create name conflicts and bugs at worst.

       

       

      My first instinct is to copy/paste everything into frame 1 of the scene that isn't a menu, but isn't there a better way? How do I stop my document script from loading until the game has begun?

        • 1. Re: If not a document class, then what?
          kglad Adobe Community Professional & MVP

          there are several 'tried and true' to ways to organize classes.  you should use one of those ways to organize your classes.

           

          everyone has their favorites.  mine is to use the document class to add and remove other class members (or instances) to the stage and handle any global things like background sound that permeates the app/game.

           

          each class member added/removed by the document class would have its own class file that handles its internal workings.  roughly, instead of changing frames to change what's displayed, different class members are added and removed.

           

          often the first class member added is an intro class member (which explains how to navigate) or menu class member (with the navigation).

          • 2. Re: If not a document class, then what?
            Q4T Level 1

            I'm not asking how to start a project, but how to salvage one. All I want to do is create a new document class script and have the current document class script called on scene 2. I'm asking literally, what I should click and/or type to make this happen.

            • 3. Re: If not a document class, then what?
              Colin Holgate MVP & Adobe Community Professional

              When you have a movieclip in the library it can be set to export for actionscript, and you would put in the location of an external Class file. If you made your current scene be a movieclip, and in the library you get the properties for the movieclip, in Advanced view you would select the export for actionscript box, and for the Class file you would enter the location of your current document class. Then you could place that movieclip on the stage and start with a new document class for the FLA.

               

              It would make sense to change some names though. For example, if your FLA is named MyGame, and your current document class is MyGame.as, you probably want to keep that the same, for the new fresh document class. So, for the new movieclip you would change the two places that say MyClass to perhaps MyClassScene1, and save that copy of the file as MyClassScene1.as. In the library movieclip properties I mentioned, you would use MyClassScene1 as the class name.

               

              Finally, in the new FLA document class you no doubt will want to keep some of the global level functions, and remove all the scene specific functions, and in the duplicate renamed MyClassScene1.as you would keep all the scene specific functions and delete any of the global functions that will now be handled by the new document class.

              1 person found this helpful
              • 4. Re: If not a document class, then what?
                Q4T Level 1

                Nice work again Colin. My brain is too sleepy right now to be able to follow those instructions, but I do think I understand.

                 

                So Ctrl + A then F8 to turn everything into a movie clip?

                • 5. Re: If not a document class, then what?
                  Colin Holgate MVP & Adobe Community Professional

                  If only it was that simple! But it's not much harder. Select all of your layers, in the layers column part of the timeline. Right-click and Copy Layers. In the library right-click and do New Symbol, make it a movieclip, with a sensible name. After you've done that you're now looking at the timeline of the movieclip. Right-click in the layers column and do a Paste Layers.

                   

                  Back in the main timeline you should now be able to delete the original layers, and drag the new movieclip out onto the stage. Then try to follow what I was saying before about the class files.

                  1 person found this helpful
                  • 6. Re: If not a document class, then what?
                    Q4T Level 1

                    Ah good. Thanks. Now it's a lot more Dummies-Guide-To. I'll try it tomorrow, though if you can see anything in there that could be dumbed down further, it might be a big help.

                    • 7. Re: If not a document class, then what?
                      Q4T Level 1

                      I've been putting this off, because I know from experience that debugging is a lot easier if the error is corrected the same day it was made. So I had to be alert and prepared for the hours upon hours of debugging that would follow this.

                       

                      Nope, worked first time.

                       

                      I'm always startled when things work the way I intended them.