After an extremely long wait, the Layout Organizers I began working on so long ago has finally been released as a full-fledged library named coordy. The code and documentation has finally reached a level of maturity where I feel comfortable offering it up to the public. The code is MIT licensed and begging to be used. Continue reading “Introducing coordy – An Actionscript 3 Layout Framework”
As a former front-end developer, I know the horrors of building HTML/CSS sites that work across all browsers. Frankly, the whole cross-browser conundrum was one reason why I got out of it a year or two ago. While I may not get paid to build static websites anymore, I obviously am still vulnerable to these problems with the sporadic interface/visual revamps I make to this blog and other minor web projects I take on. As the months go by, I see my ability to (reliably) develop HTML/CSS that will work in older browsers. That is why I really like the notion of what the Save the Developers campaign is trying to do.
I have been playing with different layout configurations lately and, after seeing the advantages/disadvantages of Flex layouts, I decided to work on this experiment. Flex layouts are great because they allow easy visual organization of elements in containers. The problem with that is once an element is in a container, it cannot easily and flexibly change its layout position. For instance, a grid cannot really turn into a HBox and definitely cannot turn into more alternative layouts (such as a circular or random layout). I decided to make some Actionscript classes that would virtually mangage layouts – no containers, just managers. Meaning you subscribe an element to a layout (or multiple layouts) and they can be put into their correct layout position (or taken away) since they act independently.
The example above is a simple example of 50 sprites – all subscribed to different layouts. Clicking each layout button applies those elements to that particular layout. That layout can be changed, which in turn changes the elements subscribed to it. Those elements can also be broken down into sub layout organizers – allowing for some pretty cool stuff. This method is pretty lightweight as well since there are no actual containers for any of these objects. The objects can be tweened (as per the example above) by defining a tween function or just directly set to their respective positions. In addition, each layout is pretty small – meaning large amounts of layouts can be created with little hit on memory. This still has a while to go, but so far it has allowed me to do some fairly interesting things pretty quickly and reliably.