8 Replies Latest reply on Oct 31, 2009 2:27 AM by Desprez10

    Improving performance with overlapping MCs?

    Desprez10

      I'm having some performance issues in certain areas of a flash game Im making.

       

      Here's the situation:

      I have big movieclip containing a map that can be scrolled and scaled. There are some pannels with a bunch of MC buttons, controls, etc. on the right side of the stage. These are seperate from the map and stay in the same place.

       

      Everything runs fine untill the large map is  zoomed in and/or scrolled such that the right side buttons and stuff are overlapping them map. Then the framerate jumps down from a nice smooth 30 fps to about 3 fps while the map is moving. There are no issues with the map moving when they don't overlap.

       

      Now the thing is, is that's there's no real interaction between the buttons and the map. No transparency or anything, in fact I'm perfectly happy with the map dissapearing behind a side pannel. There are only about 3 pannels that the screen drawing routine would have to worry about, as all the buttons rest on top of the pannels, so why is my performance taking such a hit?

       

      (Hmmm. Actually I do have a lot of transparency, but each is on top of a solid background, and none interact with the map.)

        • 1. Re: Improving performance with overlapping MCs?
          kglad Adobe Community Professional & MVP

          when not scaling (or fading or rotating etc), enable the cacheAsBitmap property of your movieclips.  disable while scaling (etc).

          • 2. Re: Improving performance with overlapping MCs?
            Desprez10 Level 1

            Ok, I orginally thought this was going to work, but it's not.

            At first, for some reason it caused all my buttons to cut holes into the panel clip that holds the buttons. Apparently, it was effectively removing them, thus speeding up the frame rate. I don't know why it was removing the buttons, but I suspected something was wonky with the buttons' internal transparency. I re-did them and removed the transparency and it fixed the buttons, but the cacheing as not increased the frame rate at all.

            • 3. Re: Improving performance with overlapping MCs?
              kglad Adobe Community Professional & MVP

              make sure you're only enabling that property for movieclips that benefit from it WHILE they benefit and disable that property when it hinders performance.  you should read about cacheAsBitmap to see when to enable and when to disable.

              • 4. Re: Improving performance with overlapping MCs?
                Desprez10 Level 1

                I did do some reading on it. I tend not to use code without understanding how it works - at least a rudimentary understanding.

                At the moment, I'm not changing anything about how the buttons look - size, rotation, placement, color, etc. This suggests that I can keep them cached starting at runtime while testing the cacheing. (Though I also tried caching them when starting the simulation, and disableing cacheing when the buttons could be used, too.)

                 

                Basicaly, I have a game where you use the buttons to supply program commands to robots on the map. Once this is done, you run the program, and the robots execute their programing. Meaning that you can't issue new commands while they are running (and the map is moving), so the buttons are disabled. So there is no reason they would need to change in appearance. When in the 'programing' stage, the map is not moving because the sim is not running. This seems to suggest that cacheAsBitmap could be enabled at all times.

                 

                At the moment, I've had to resort to making the _visible property of the button pannel = false during the sim stage. However, this is not an ideal solution, it's just what I've had to resort to to be able to test the workings of the game. eventually, I'll want the player to be able to see how the commands are executing while the sim is running.

                • 5. Re: Improving performance with overlapping MCs?
                  kglad Adobe Community Professional & MVP

                  it's probably your map that's the problem because it's large.  either that or, you have hundreds of other movieclips that in combination with a large map is causing the problem.

                   

                  and your map is scaled so you don't want to enable it's cab property while it's scaling.  however, when not scaling it sounds like you can enable its cab and realize a performance benefit.

                  • 6. Re: Improving performance with overlapping MCs?
                    Desprez10 Level 1

                    Right now, the map is a just solid color with a few lines.

                    I only have 20-60 buttons.

                    I already took map scaling out of the equation.

                    I tried caching the map too, it didn't help.

                    • 7. Re: Improving performance with overlapping MCs?
                      kglad Adobe Community Professional & MVP

                      then i assume you're having problems only when scrolling your map.  with less than 100 movieclips on stage you wouldn't expect a performance problem unless you have a coding issue or a computer with less than 2 gigs of ram or a slow cpu.

                      • 8. Re: Improving performance with overlapping MCs?
                        Desprez10 Level 1

                        It was both scrolling and scaling, but only when the buttons appeared over it. I took out scaling to test caching.

                         

                        My computer is fine, so it must be a code issue, then. I'm not happy with how it works at the moment anyway, as it will only recognize modifier keys and arrows. I tried doing it using a different technique I was online somewhere, but that made the framerate worse. I'll have to take another stab at it.