• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

If not a document class, then what?

Contributor ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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?

Views

349

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 08, 2016 Dec 08, 2016

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.

...

Votes

Translate

Translate
Community Expert ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 08, 2016 Dec 08, 2016

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 12, 2016 Dec 12, 2016

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines