AARON SMITH’S CODE ENDEAVOR

More Guttershark Updates

Recently I put up some updates to guttershark - they sucked, so I’ve got another update. I was getting tired of having to include 90K for any swf that uses GS. So I went through and decoupled quite a bit.

Primarily it was all the singletons that were included. Originally, when I wrote the first version of GS I used all the singletons for performance and speed, but for how often some of those utilities are used it really doesn’t matter. And if you use FDT or Flex Builder, importing everything you need will be auto-completed anyways. So who cares!

The first version of GS included a couple classes called CoreSprite, and CoreClip - they included properties so that you’d always have access to a bunch of stuff, like a Model for instance. Instead of that, your class should create it’s own model, save it, and import it in any class that uses it.

You can still create your own base classes that contain properties you use all the time, but I’m not going to tell you what you need and what you don’t need; this is one of the reasons why GS would include everything if you subclassed either CoreSprite or CoreClip. So for any project you have, write your own base classes that included references to the things you need; that’s what I do.

Here’s a contrived example.

class Main
{
    var model:Model;
    function Main()
    {
         model = new Model();
         Model.set("main",model);
    }
}
 
class AnotherClass
{
    private var model:Model;
    public function AnotherClass
    {
        model = Model.get("main");
    }
}

There are a number other classes that have this type of functionality on it. You can find them in the docs. Anyway, I’m much happier with this. Generally a shell swf will end up being around 35K.

There are a crap ton of examples in the repository. Make sure to check those out, you might see how awesome GS is and how much time it’ll save you.

If you wrote anything with GS in V1 or V2, you won’t be able to swap it out for GS3 without making some updates. The most notable things I changed:

  • Took out CoreClip and CoreSprite. There’s GSClip or GSSprite now, but only fixes null stage references.
  • Most utility classes have static methods on them instead of singletons.
  • AssetManager is static
  • Re-ordered method parameters on the LayoutManager to use …rest style parameters
  • There’s a new DocumentController class which is simpler.
  • Added a new TextAttributes class (gs.utils.TextAttributes). And added new model functionality to simplify setting text attributes on text fields. Like stylesheets, textformats, etc. Now it’s a one liner to set text attributes.

Additionally, I’ve updated the repositories on my gitweb page. The guttershark repo is the latest version, and I’ve updated the docs. You won’t need to look for gs2 docs or the gs2 repo anymore.

  

1 Comment so far

  1. Nicholas Shipes March 4th, 2010 12:26 pm

    I’m using your framework for my application, which will eventually be an AIR application. When I try testing as an AIR application within the Flash IDE, I instantly receive this error from the DocumentController.startPreload method:

    Error: The model xml must be set on the model before attempting to read a property from it.

    However, it works fine as a regular Flash application and I’m not receiving any IO/security errors when loading the model XML. Since startPreload() is called within the onModelReady() method, it’s clearly loading, but the xml data is not being set on it.

    Any ideas?

    Thanks in advance!

Leave a reply