-
Notifications
You must be signed in to change notification settings - Fork 0
ObjectBuilder
ObjectBuilder is an ActionScript3 language extension, that is intended to automate complicated objects creation in declarative style. In other words, ObjectBuilder is a template related a class. This template can contain:
- class properties block
- event description block
- children block
- init block
- constructor parameters block
##ObjectBuilder Blocks ###class properties block
Class properties block is intended to fill out all the possible properties of a class in a simple and compact declarative mode.
Sprite{
x : 200;
y : 300;
};Event description block contains all information related with events handling of a class.
TextField{
text : "Hello World";
onClick : {e =>
this.setTextFormat(TextFormat(<font:String>){
font : "_serif";
size : 20;
align : TextFormatAlign.LEFT;
});
};
}Children block contains ObjectBuilders for all children of a parent object. This feature is available only for DisplayObject children.
Sprite{
children :
[
TextField{
text : "Hello World!";
}
];
children :
[
SimpleButton(<upState:DisplayObject>){
name : "myButton";
}
];
};Init block is executed on instance creation. Extremely useful when you need this statement.
Sprite{
init : { =>
with (this.graphics) {
beginFill(0x000000, .4);
drawRect(0, 0, 600, 400);
}
};
};###constructor parameters block
Optional block, that appears only if the parent class has parameters.
public function myClass(a : int, b : int) {
...
}
public function method() : void
{
myClass(1, 2){
<<...>>
};
}