User Guide

178 Creating Components
name_label._y = 10;
name_ti = createObject("TextInput", "name_ti",
this.startDepth++,{_width:200,_heigh:22,_x:20,_y:30});
name_ti.html = false;
name_ti.text = __name;
name_ti.tabIndex = 1;
/* Set this text input field to have focus.
Note: Make sure to set select Control > Disable Keyboard Shortcuts
in the Flash Debugger if it is not already selected, otherwise
the focus may not set when testing. */
name_ti.setFocus();
name_label = createObject("Label", "password_label",
this.startDepth++,{_width:200,_heigh:22,_x:20,_y:60});
name_label.text = "Password:";
password_ti = createObject("TextInput", "password_ti",
this.startDepth++,{_width:200,_heigh:22,_x:20,_y:80});
password_ti.html = false;
password_ti.text = __password;
password_ti.password = true;
password_ti.tabIndex = 2;
login_btn = createObject("Button", "login_btn",
this.startDepth++,{_width:80,_heigh:22,_x:240,_y:80});
login_btn.label = "LogIn";
login_btn.tabIndex = 3;
login_btn.addEventListener("click", this);
size();
}
/* The draw method is required for v2 components.
It is invoked after the component has been
invalidated by someone calling invalidate().
This batch’s up the changes into one redraw, rather
than doing them all individually. This approach leads
to more efficiency and better centralization of code. */
function draw():Void {
super.draw();
}
/* The size method is invoked when the component's size
changes. This is an opportunity to resize the children,
The size method is required for components extending UIComponent. */
function size():Void {
super.size();
// Cause a redraw in case it is needed.