如何为 Flex 中的按钮分配自动递增的 id 名称
我是Flex方面的业余爱好者,并开始了我在Flex方面的最后一年项目来学习它,当用户按下“添加更多”时,我陷入了必须创建下拉列表行的位置,例如:就像
我认为的 邮件附件中的那些一样我找到了一种生成行的方法,我什至不确定这是否是正确的方法,可能有简单的方法..如果是这样,请告诉我 这就是我生成行的方式:
<mx:states>
<mx:State name="newRow">
<mx:AddChild relativeTo="{cityDropdown}">
<s:DropDownList id="newbutton" creationComplete="hotelDropdown_creationCompleteHandler(event)" labelField="Name">
<s:AsyncListView list="{getAllHotelResult.lastResult}"/>
</s:DropDownList>
</mx:AddChild>
</mx:State>
</mx:states>
现在,当我生成更多行时,下拉列表 id 会发生冲突,所以我想知道一种生成 id 的方法,我想我什至无法调用其中的函数:(
请帮忙...截止日期是靠近 :(
i am amateur in flex, and started my final year project in flex to learn it, i am stuck in place where i have to create rows of drop down lists when the user pressed add more, eg: like the ones in mail attachments
i think i have found a way to generate rows, i am not even sure whether it is a correct way, may be there are easy ways..if so please let me know
this is how i generate the rows:
<mx:states>
<mx:State name="newRow">
<mx:AddChild relativeTo="{cityDropdown}">
<s:DropDownList id="newbutton" creationComplete="hotelDropdown_creationCompleteHandler(event)" labelField="Name">
<s:AsyncListView list="{getAllHotelResult.lastResult}"/>
</s:DropDownList>
</mx:AddChild>
</mx:State>
</mx:states>
now when i generate more rows the dropdownlist ids will conflict, so i want to know a way to generate ids, i think i cant even call a function in there :(
please help...deadline is near :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
碰巧我最近创建了一些非常相似的东西,但是使用 ComboBoxes 而不是 DropDownList - 用户可以单击“添加更多”,新的 ComboBox 将在新行上向下滑动(右键单击我网站上的演示以查看源代码 - 下面的链接)。
或许你能从中得到一些启发。
要自动递增 id 名称,您必须执行一些 AS3 编码。每次创建按钮时,其名称将变为“whaterver”+ i(i 作为 int 每次递增)
http://bbishop.org/blog/?p=448
It just happens that I created something very similar recently, but using ComboBoxes rather than DropDownList - where the user can click Add More and a new ComboBox will slide down on a new row (right click the demo on my site to View Source - link below).
Maybe you can get some inspiration from that.
To auto increment the id names, you going to have to do some AS3 coding. Each time a button is created, its name will become "whaterver" + i (with i as an int incrementing each time)
http://bbishop.org/blog/?p=448
我不明白你使用的状态,但是为了进行多动态生成视图,我选择使用“事件冒泡”策略并让控件没有id。
将控件包装到一个组件中,而不是使事件从组件中冒泡。而不是在控件的父级上添加侦听器。就这样。
i don't understand about the state you used, but to do multi dynamic generated view, i choose to use "Event Bubbling" strategy and let the control without id.
wrap your controls into one component than make the event bubble from the component. than add listener on the parent of the control. thats all.