Thursday, September 5, 2013

Dynamic Text Box in Flex


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

initialize="application1_creationCompleteHandler(event)" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx1="library://ns.adobe.com/flex/mx">


<mx:Script>
<![CDATA[
import mx.events.FlexEvent;


protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var txt:txtbox=new txtbox();
app_Vbx.addChild(txt);
}
]]>
</mx:Script>
<mx1:VBox id="app_Vbx" height="100%" width="100%">

</mx1:VBox>
</mx:Application>


package
{
import mx.containers.HBox;
import mx.containers.VBox;
import mx.controls.Alert;
import mx.controls.Label;
import mx.controls.TextInput;
import spark.components.HGroup;
import spark.components.VGroup;

public class txtbox extends VGroup
{
public function txtbox()
{
super();
this.percentHeight = 100;
this.percentWidth = 100;
Alert.show("txtbox" );
}
override protected function createChildren():void
{
Alert.show("text" );
var hbx:HGroup = new HGroup();
var txt1:TextInput = new TextInput();
txt1.percentHeight = 75;
txt1.percentWidth = 75;
var txt2:TextInput = new TextInput();
var txt3:TextInput = new TextInput();
var lbl:Label = new Label();
lbl.text="Sample";
hbx.height = 500;
hbx.width = 500;
hbx.addElement(lbl);
hbx.addElement(txt1);
hbx.addElement(txt2);
hbx.addElement(txt3);
addElement(hbx);
}
}
}

No comments:

Post a Comment