Prev | Current Page 711 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Elements can be added and removed using the
setElement() and removeElement() methods. The setElement() accepts as arguments, an element
and the row and column position. Empty cells are rendered as empty regions. The class has a variable
spacing that specifies the distance between two adjacent cells both horizontally and vertically.
In Figure 13-5 a GridLayout with four columns and four rows has been created. Each control completely
fits the available area and resizes itself when the view is resized.
Part II: Server Side, JavaScript, and Flash: Oh My!
380
Figure 13 - 5
import ui.core.Layout;
import ui.controls.Button;
import ui.flash9.StageView;
import ui.containers.GridLayout;
class Main
{
public static function main()
{
Chapter 13: Replacing the Need for an IDE
381
var view = new StageView();
var t = 4;
var grid = new GridLayout(t, t);
grid.hLayout = grid.vLayout = Margins(10);
grid.spacing = 5.0;
view.addChild(grid);
for(r in 0...t)
for(c in 0...t)
{
var b = new Button(Std.string(c+r*t+1));
b.


Pages:
699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723