Actionscript 3 列出组件以显示输入文本框
我正在创建一个列表组件,每个标签上的数字从1到10不等。当点击一个数字时,我需要它一个接一个地显示那么多输入文本框Actionscript 3 列出组件以显示输入文本框,actionscript-3,flash,list,multiplayer,textinput,Actionscript 3,Flash,List,Multiplayer,Textinput,我正在创建一个列表组件,每个标签上的数字从1到10不等。当点击一个数字时,我需要它一个接一个地显示那么多输入文本框 这几乎是一个多人游戏,你可以选择有多少玩家在玩,然后输入每个名字。。我被卡住了,这太荒谬了。。如果有人有解决方案或不同的想法,请帮助我,提前非常感谢。有很多方法可以实现这一点 Flash专业方法 在Flash Professional的艺术板上发表您的观点 包括列表控件以及要显示的文本框,例如: 为组件指定属性名称,例如列表的quantityList,以及回答文本输入控件,例如a
这几乎是一个多人游戏,你可以选择有多少玩家在玩,然后输入每个名字。。我被卡住了,这太荒谬了。。如果有人有解决方案或不同的想法,请帮助我,提前非常感谢。有很多方法可以实现这一点 Flash专业方法 在Flash Professional的艺术板上发表您的观点 包括列表控件以及要显示的文本框,例如: 为组件指定属性名称,例如列表的
quantityList
,以及回答文本输入控件,例如answer1
在answerbox
自定义符号内
在代码中,您可以通过将以下内容添加到时间线来控制答案视图的可见性:
import flash.events.Event;
quantityList.addItem({label:"1", data:1});
quantityList.addItem({label:"2", data:2});
quantityList.addItem({label:"3", data:3});
quantityList.addItem({label:"4", data:4});
quantityList.addItem({label:"5", data:5});
quantityList.addItem({label:"6", data:6});
quantityList.addItem({label:"7", data:7});
quantityList.addItem({label:"8", data:8});
quantityList.addItem({label:"9", data:9});
quantityList.addItem({label:"10", data:10});
quantityList.addEventListener(Event.CHANGE, changeHandler);
function changeHandler(event:Event):void
{
var numberOfQuestions = event.target.selectedItem.data as int;
answerBoxes.answer1.visible = (numberOfQuestions > 0 ? true : false);
answerBoxes.answer2.visible = (numberOfQuestions > 1 ? true : false);
answerBoxes.answer3.visible = (numberOfQuestions > 2 ? true : false);
answerBoxes.answer4.visible = (numberOfQuestions > 3 ? true : false);
answerBoxes.answer5.visible = (numberOfQuestions > 4 ? true : false);
answerBoxes.answer6.visible = (numberOfQuestions > 5 ? true : false);
answerBoxes.answer7.visible = (numberOfQuestions > 6 ? true : false);
answerBoxes.answer8.visible = (numberOfQuestions > 7 ? true : false);
answerBoxes.answer9.visible = (numberOfQuestions > 8 ? true : false);
answerBoxes.answer10.visible = (numberOfQuestions > 9 ? true : false);
}
运行时,可以从列表中选择项目:
Flex-一种程序化方法
在列表数据提供程序中存储数量值,并在更改时迭代添加元素:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import spark.components.TextInput;
import spark.events.IndexChangeEvent;
protected function quantityList_changeHandler(event:IndexChangeEvent):void
{
textInputGroup.removeAllElements();
for (var i:uint = 0; i < quantityList.selectedItem; i++)
{
textInputGroup.addElement(new TextInput());
}
}
]]>
</fx:Script>
<s:List id="quantityList"
change="quantityList_changeHandler(event)"
dataProvider="{new ArrayList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}" />
<s:VGroup id="textInputGroup" />
</s:Application>
Flex-一种声明性方法
使用Flex状态系统,您可以声明性地布局视图,然后包括处于所需状态的组件。您还可以为动画合并状态之间的转换
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import spark.components.TextInput;
import spark.events.IndexChangeEvent;
protected function quantityList_changeHandler(event:IndexChangeEvent):void
{
currentState = "quantity" + quantityList.selectedItem.toString();
}
]]>
</fx:Script>
<s:states>
<s:State name="quantity1" />
<s:State name="quantity2" />
<s:State name="quantity3" />
<s:State name="quantity4" />
<s:State name="quantity5" />
<s:State name="quantity6" />
<s:State name="quantity7" />
<s:State name="quantity8" />
<s:State name="quantity9" />
<s:State name="quantity10" />
</s:states>
<s:List id="quantityList"
change="quantityList_changeHandler(event)"
dataProvider="{new ArrayList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}" />
<s:VGroup id="textInputGroup">
<s:TextInput includeIn="quantity1,quantity2,quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity2,quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity9,quantity10" />
<s:TextInput includeIn="quantity10" />
</s:VGroup>
</s:Application>
实现这一点的方法有很多 Flash专业方法 在Flash Professional的艺术板上发表您的观点 包括列表控件以及要显示的文本框,例如: 为组件指定属性名称,例如列表的
quantityList
,以及回答文本输入控件,例如answer1
在answerbox
自定义符号内
在代码中,您可以通过将以下内容添加到时间线来控制答案视图的可见性:
import flash.events.Event;
quantityList.addItem({label:"1", data:1});
quantityList.addItem({label:"2", data:2});
quantityList.addItem({label:"3", data:3});
quantityList.addItem({label:"4", data:4});
quantityList.addItem({label:"5", data:5});
quantityList.addItem({label:"6", data:6});
quantityList.addItem({label:"7", data:7});
quantityList.addItem({label:"8", data:8});
quantityList.addItem({label:"9", data:9});
quantityList.addItem({label:"10", data:10});
quantityList.addEventListener(Event.CHANGE, changeHandler);
function changeHandler(event:Event):void
{
var numberOfQuestions = event.target.selectedItem.data as int;
answerBoxes.answer1.visible = (numberOfQuestions > 0 ? true : false);
answerBoxes.answer2.visible = (numberOfQuestions > 1 ? true : false);
answerBoxes.answer3.visible = (numberOfQuestions > 2 ? true : false);
answerBoxes.answer4.visible = (numberOfQuestions > 3 ? true : false);
answerBoxes.answer5.visible = (numberOfQuestions > 4 ? true : false);
answerBoxes.answer6.visible = (numberOfQuestions > 5 ? true : false);
answerBoxes.answer7.visible = (numberOfQuestions > 6 ? true : false);
answerBoxes.answer8.visible = (numberOfQuestions > 7 ? true : false);
answerBoxes.answer9.visible = (numberOfQuestions > 8 ? true : false);
answerBoxes.answer10.visible = (numberOfQuestions > 9 ? true : false);
}
运行时,可以从列表中选择项目:
Flex-一种程序化方法
在列表数据提供程序中存储数量值,并在更改时迭代添加元素:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import spark.components.TextInput;
import spark.events.IndexChangeEvent;
protected function quantityList_changeHandler(event:IndexChangeEvent):void
{
textInputGroup.removeAllElements();
for (var i:uint = 0; i < quantityList.selectedItem; i++)
{
textInputGroup.addElement(new TextInput());
}
}
]]>
</fx:Script>
<s:List id="quantityList"
change="quantityList_changeHandler(event)"
dataProvider="{new ArrayList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}" />
<s:VGroup id="textInputGroup" />
</s:Application>
Flex-一种声明性方法
使用Flex状态系统,您可以声明性地布局视图,然后包括处于所需状态的组件。您还可以为动画合并状态之间的转换
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:HorizontalLayout />
</s:layout>
<fx:Script>
<![CDATA[
import mx.collections.ArrayList;
import spark.components.TextInput;
import spark.events.IndexChangeEvent;
protected function quantityList_changeHandler(event:IndexChangeEvent):void
{
currentState = "quantity" + quantityList.selectedItem.toString();
}
]]>
</fx:Script>
<s:states>
<s:State name="quantity1" />
<s:State name="quantity2" />
<s:State name="quantity3" />
<s:State name="quantity4" />
<s:State name="quantity5" />
<s:State name="quantity6" />
<s:State name="quantity7" />
<s:State name="quantity8" />
<s:State name="quantity9" />
<s:State name="quantity10" />
</s:states>
<s:List id="quantityList"
change="quantityList_changeHandler(event)"
dataProvider="{new ArrayList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])}" />
<s:VGroup id="textInputGroup">
<s:TextInput includeIn="quantity1,quantity2,quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity2,quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity3,quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity4,quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity5,quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity6,quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity7,quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity8,quantity9,quantity10" />
<s:TextInput includeIn="quantity9,quantity10" />
<s:TextInput includeIn="quantity10" />
</s:VGroup>
</s:Application>
老兄,我对这一点太陌生了,我不知道如何在actionscript中使用这些东西..见鬼,我甚至说这可能听起来很无知,因为我确信它不像。。谢谢你迄今为止的帮助……哦,你想要一个Flash Pro的例子。抱歉,基本上与侦听事件的编程方法相同。请从列表中更改。我很快会尝试添加这个例子。老兄,非常感谢你,我会想办法提高我在这个网站上的声誉,这样我就可以对你的答案进行投票。。非常感谢男人…更新,包括一个。谢谢你帮助我的男人。我还有一个问题,我不打扰你了。PFPDEV推出了一款名为“饮酒游戏”的android应用程序。有一个多人游戏提示,询问有多少玩家,然后弹出那么多文本输入框,让他们输入姓名。我想做的基本上是。。在提交他们的名字后,我希望顶部有一个文本框,一帧一帧地显示每个名字。你有时间帮我吗?还有,你有贝宝吗?我想补偿你,当我推出这个应用程序时,我知道我的朋友们至少会买它。伙计,我对这个太陌生了,我不知道如何在actionscript中使用这些东西..见鬼,我甚至说这听起来可能很无知,因为我确信它不像。。谢谢你迄今为止的帮助……哦,你想要一个Flash Pro的例子。抱歉,基本上与侦听事件的编程方法相同。请从列表中更改。我很快会尝试添加这个例子。老兄,非常感谢你,我会想办法提高我在这个网站上的声誉,这样我就可以对你的答案进行投票。。非常感谢男人…更新,包括一个。谢谢你帮助我的男人。我还有一个问题,我不打扰你了。PFPDEV推出了一款名为“饮酒游戏”的android应用程序。有一个多人游戏提示,询问有多少玩家,然后弹出那么多文本输入框,让他们输入姓名。我想做的基本上是。。在提交他们的名字后,我希望顶部有一个文本框,一帧一帧地显示每个名字。你有时间帮我吗?还有,你有贝宝吗?当我知道我的朋友们至少会买这个应用程序时,我想补偿你。