No description, website, or topics provided.
ActionScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea
libs
src/net/wooga/displaytreebuilder
test
testLibs
.gitignore
DisplayTreeBuilder.iml
LICENSE
readme.markdown

readme.markdown

#Display Tree Builder

A declarative language to set up trees of display objects.

###Example

var displayTree:DisplayTree = new DisplayTree();

displayTree. uses(rootView). containing.

	//Adds a Sprite with the name "Menu", containing one
	//instance of each FullScreenButton and EditButton
	a (Sprite). withTheName ("Menu"). containing.
		a (FullScreenButton).
		an (EditButton).
	end.

	//Adds 3 instances of Container, each with
	//a single instance of Icon
	times (3). a (Container). containing.
		an (Icon).
	end.
end.finish();

The DSL only allows terms where they make sense (e.g. you can not place withName after times(x)). This is especially useful in IDEs with code completion. [Warning: This feature is currently a bit shaky, so don't lean on it to heavily.]

####Creating display objects from data

It is also possible to create a display object for every item in a collection, using the item to initialize the object.

displayTree. uses (rootView). containing.

    a (Sprite). forEveryItemIn (["Spades", "Hearts", "Diamonds", "Clubs"]).
	    withTheProperty ("name"). setToThe. item

end.finish();

The collection can be an Array, a Vector, an IIterable or an IIterator (the last two from the AS3Commons Collections library)