var LoginForm:Form = new Form();
and for FormItem
var userItem:FormItem = new FormItem();
var passwordItem:FormItem = new FormItem();
In this example two text box is created in actionscript and added to the FormItem like
userItem.addChild(userBox);
passwordItem.addChild(passwordBox);
Then these two FormItem will be added to a Form which we created in the top by
LoginForm.addChild(userItem);
LoginForm.addChild(passwordItem);
At last the Form will be added to a container say HBox or VBox or any container
The full source code is
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
<mx:VBox id="container" width="100%" height="100%">
</mx:VBox>
<mx:Script>
<![CDATA[
import mx.controls.TextInput;
import mx.containers.FormItem;
import mx.containers.Form;
private function init():void
{
var LoginForm:Form = new Form();
var userItem:FormItem = new FormItem();
userItem.label="Username";
var userBox:TextInput=new TextInput();
userItem.addChild(userBox);
LoginForm.addChild(userItem);
var passwordItem:FormItem = new FormItem();
passwordItem.label="Password";
var passwordBox:TextInput=new TextInput();
passwordItem.addChild(passwordBox);
LoginForm.addChild(passwordItem);
container.addChild(LoginForm);
}
]]>
</mx:Script>
</mx:Application>
See how it works
No comments:
Post a Comment