What is Nimble?
Nimble is an open source and lightweight framework to easily achieve a fluid layout within a Flash application using ActionScript 3.0. But what do I mean with the phrase “fluid layout”? Let’s have a look at the following graphic:
Have a look a an example and resize the browser window a few times to see the efficiency.
How do I use Nimble?
Using Nimble is pretty easy. Looking at the most basic situation, we want to center a display object, we would only need one line of code:
new Nimble(displayObject);
This line of code would position displayObject in the center of the stage and would always align it to the new center if the browser window is resized.
Nimble offers two parameters we can set:
- alignment : String
- “TOP_LEFT”
- “TOP”
- “TOP_RIGHT”
- “LEFT”
- “MIDDLE” (default)
- “RIGHT”
- “BOTTOM_LEFT”
- “BOTTOM”
- “BOTTOM_RIGHT”
- margin : Number
- 0 (default)
Now we want to position another display object in the bottom right corner of the stage with a margin of 20 pixels. To achieve this using Nimble, we want to pass a parameter object to the Nimble constrcutor which holds the information about this positioning action:
new Nimble(displayObject, {alignment: "BOTTOM_RIGHT", margin: 20});
Of course you can store any Nimble in a variable. This would come handy if you want to change the alignment later on with the property parameterObject:
var contentNimble:Nimble = new Nimble(displayObject);
contentNimble.parameterObject = {alignment: "TOP_LEFT", margin: 20};
Where can I get Nimble?
You can download the source code at my github profile aidentailor. It is released under a MIT open source license and is free for private and commercial use.
Nimble, by this time, is in a very early state and I will improve it over time.
Now have fun with it!
Tags: ActionScript, layout

