2 Replies Latest reply on Jul 8, 2009 10:33 AM by meshgraphics

    Dynamic or Static Class

    meshgraphics Level 2

      Dynamic or Static Objects

       

      It seems to me there is a big cliff at the point of deciding to instantiate your class at runtime or static load

      on start-up.

       

      My swf apps have a pent-up burst that happens a couple seconds into the run. I think I get this on most

      web pages that have flash banners.

       

      Flash apps that have a loader bar can take 60 secs. These ones usually come on with a bang with a lot of

      high quality graphics.

       

      Therer is a big processor spike at start-up with the browser loading http page. Flash seems to want a big spike

      with its initial load. The javascript embed doesn't help either.

       

       

      How to get a smooth start-up? Me English good.

       

       

        • 1. Re: Dynamic or Static Class
          istrasci Level 1

          This seems like a matter of correctness, only indirectly relating to speed.

           

          The speed that a SWF loads from a web page is determined by many things, like server connection speed, client connection speed, browser cache size, client RAM, etc.  Having static vs. dynamic classes would not impact this very much.

           

          First of all, "static objects" is kind of an oxymoron because you can't instantiate (create an object) of a static class.  I would say that having static variables/methods in a class is usually when you want some shared values/functionality without requiring an actual object (taking up memory) -- although static practices certainly extend beyond just this.  I always try to think of a Math class.  You wouldn't have to have to say m = new Math() just to use some common methods (square, sin, cos, etc.) or values (pi, e, etc.).  They become kind of like "global constants/methods" in a sense (not to invoke the debate over correctness of that wording).

           

          In short, it's more of a memory issue, which will like not have much influence over loading speed.  If you want to improve your loading speed, you can try to delay the creation of your objects based on certain events instead of having them all load at startup.

           

          How to get a smooth start-up? Me English good.

           

           

          • 2. Re: Dynamic or Static Class
            meshgraphics Level 2

            Yes, if you make static classes you should make them with a Capital letter and use the class name.

             

            If you put buttons on your form, they will be instantiated at start-up.  They will increase the swf size, thus reducing your start time.

             

            If you instantiate buttons in actionscript your page changes could be slower.