我想添加一个按钮,单击该按钮会添加另一个文本字段。我正在使用adobe flash builder来编写应用程序,因此它需要使用MXML或actionscript。关于如何做到这一点的任何想法?
eventhandler按钮当前指向此代码,但是在第一次添加文本框后,它会停止并且不再添加。如何在每次单击按钮时设置循环以继续添加文本字段?
<fx:Script>
<![CDATA[
protected function tableID(event:MouseEvent):void
{
var name:TextInput = new TextInput;
addElement(name);
name.move(50, 200);
}
]]>
</fx:Script>
MXML:
<s:Button id="addBtn" x="175" y="450" label="+" click="tableID(event)" />
答案 0 :(得分:0)
只需对文本字段使用布尔变量即可。为includeInLayout&amp;设置变量。对于文本字段可见。单击该按钮时,将布尔变量的条件设置为true或false。我想这会帮助你。
答案 1 :(得分:0)
您可以尝试这种方式:
<fx:Script>
<![CDATA[
import mx.controls.TextInput;
protected function bt_clickHandler(event:MouseEvent):void
{
// TODO Auto-generated method stub
var item:TextInput = new TextInput();
item.width = 50;
_parent.addElement(item);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:Tile id="_parent" width="100%" height="100%">
<s:Button id="bt" label="+" click="bt_clickHandler(event)"/>
</mx:Tile>