Apache flex Flex获取Hgroup的第一个对象
我的代码介绍:我在一个滚动条中有一个Vgroup,因为用户要添加一些对象 每次用户单击按钮时,它都会添加到包含3个对象的Vgroup和Hgroup中(查看agregar_clickhandler)。这三个对象是文本输入、数字步进和删除图标 我想做的是在用户每次编辑时提取每个Hgroup内的textinput和numeric stepper中的信息 例如,当我必须删除一个Hgroup时,我会使用Eliminar函数,它工作得很好。我试图做一些类似的事情来获取textInput中的文本,但没有任何效果 我所做的是在TextInput中添加一个事件侦听器,这样当用户键入某个内容时,我就可以提取该信息 我感谢你的帮助Apache flex Flex获取Hgroup的第一个对象,apache-flex,flex4,flex3,flexbuilder,Apache Flex,Flex4,Flex3,Flexbuilder,我的代码介绍:我在一个滚动条中有一个Vgroup,因为用户要添加一些对象 每次用户单击按钮时,它都会添加到包含3个对象的Vgroup和Hgroup中(查看agregar_clickhandler)。这三个对象是文本输入、数字步进和删除图标 我想做的是在用户每次编辑时提取每个Hgroup内的textinput和numeric stepper中的信息 例如,当我必须删除一个Hgroup时,我会使用Eliminar函数,它工作得很好。我试图做一些类似的事情来获取textInput中的文本,但没有任何效
<s:Button id="agregar" x="36" y="533" label="Agregar mas mensajes " fontSize="20"
click="agregar_clickHandler(event)"/>
<s:Scroller x="36" y="99" width="554" height="400">
<s:VGroup width="100%" height="100%" id="scroller">
</s:VGroup>
</s:Scroller>
protected function agregar_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
var group:HGroup = new HGroup();
group.width = 552;
group.height = 65;
var input:TextInput = new TextInput();
input.width = 360;
input.height = 49;
input.addEventListener(TextOperationEvent.CHANGE, actualizar);
var num:NumericStepper = new NumericStepper();
num.width = 107;
num.height = 49;
num.maximum = 100;
var del:Button = new Button();
del.width = 70;
del.height = 49;
del.label = "delete";
del.setStyle("icon", deleteicon);
del.addEventListener(MouseEvent.CLICK, eliminar);
group.addElement(input);
group.addElement(num);
group.addElement(del);
scroller.addElement(group);
}
protected function eliminar(event:MouseEvent):void
{
scroller.removeElement(HGroup(Button(event.currentTarget).parent));
}
protected function actualizar(event:TextOperationEvent):void
{
var obj:Object = scroller.getElementIndex(HGroup(TextInput(event.currentTarget).parent));
}
受保护函数agregar\u clickHandler(事件:MouseEvent):无效
{
//TODO自动生成的方法存根
变量组:HGroup=newhgroup();
组宽=552;
组:身高=65;
变量输入:TextInput=新的TextInput();
input.width=360;
输入高度=49;
input.addEventListener(TextOperationEvent.CHANGE,actualizar);
var num:NumericStepper=新的NumericStepper();
num.width=107;
num.height=49;
最大数量=100;
var del:Button=new Button();
del.width=70;
del.height=49;
del.label=“删除”;
删除设置样式(“图标”,删除图标);
del.addEventListener(MouseEvent.CLICK,eliminar);
组.加法(输入);
添加元素组(num);
添加元素组(del);
添加元素(组);
}
受保护函数eliminar(事件:MouseEvent):无效
{
scroller.removelement(HGroup(按钮(event.currentTarget.parent));
}
受保护的函数实现(事件:TextOperationEvent):无效
{
var obj:Object=scroller.getElementIndex(HGroup(TextInput(event.currentTarget.parent));
}
试试这个:
protected function actualizar(event:TextOperationEvent):void
{
var currentHGroup:HGroup = HGroup(TextInput(event.currentTarget).parent);
var currentText:String = (currentHGroup.getElementAt(0) as TextInput).text;
var currentNumber:int = (currentHGroup.getElementAt(1) as NumericStepper).value;
}
您应该使用数据组或列表组件通过ItemRenders动态添加和删除视图。看看这个问题的答案: