I am trying to implement reusable components in flex 3. I have tab navigator which will be dynamic.In the screen i have a button with click operation a tab navigator wiht vbox as child will be created and in vbox i have one textbox which takes input information from user.
I have a show button beside the click button. when a user click show button and if the four tabs are opened we need to put all of the textboxes of the VBox to the Text Area.
here is my code.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import Repeat;
private var input:String;
private var i:int=0;
private function addNextTab(event:Event):void {
tabs.addChild(new Repeat("Tab"));
}
private function show()
{
var child:DisplayObject;
for(i=0;i<tabs.numChildren;i++)
{
child=tabs.getChildAt(i);
input=TextInput(child.getChildAt(0)).text;//error
textArea.text=textArea.text+input;
}
}
]]>
</mx:Script>
<mx:TabNavigator id="tabs" width="100%" height="100%">
</mx:TabNavigator>
<mx:TextArea id="textArea"/>
<mx:Button label="Add Next Tab" click="addNextTab(event)" />
<mx:Button label="Show Values" click="show()" />
</mx:Application>
the one line is showing the errors. I am intial learner on the flex. But i tried to learn and do my own.
here is my Repeat.as
package {
import mx.containers.VBox;
import mx.controls.Label;
import mx.controls.TextInput;
public class Repeat extends VBox {
public function Repeat(name:String) {
label = name;
}
override protected function createChildren():void {
super.createChildren();
var box:VBox = new VBox();
var t1:TextInput = new TextInput();
box.addChild(t1);
addChild(box);
}
}
}
i have to access the text box information of all the tabs and put it in textArea.
can any body help me.?
BTW: It is flex 3 application.
You should make text a public property and don’t create a nested VBox to add it to. You are already extending VBox, so just addChild.. like this:
EDIT: show to access it.