AS3组合框“onSelect”更改

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3组合框“onSelect”更改相关的知识,希望对你有一定的参考价值。

I copied this from my working example and tweaked some lines to make it generic. Thus there MAY be a typo which I haven't checked for, but probably not. This is what's needed to have something change upon selection of an item in a ComboBox.
  1. // this code assumes the existance of a ComboBox (Components -> User Interface -> ComboBox)
  2. // on the stage with an instance name of "MY_DROPDOWN_INSTANCE_NAME" plus two items defined in its properties
  3. // named "Choice One" and "Choice Two"
  4.  
  5. var MY_DROPDOWN_LISTENER:Object=new Object(); // a new listener
  6. MY_DROPDOWN_INSTANCE_NAME.addEventListener("change", MY_DROPDOWN_LISTENER); //add listener to combobox
  7. MY_DROPDOWN_LISTENER.change=function(){ //function called
  8. // do something based on the selected item's label
  9. switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().label) {
  10. case "Choice One":
  11. trace("one");
  12. break;
  13. case "Choice Two":
  14. trace("two");
  15. break;
  16. }
  17.  
  18. // do something based on the selected item's value
  19. switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().data) {
  20. case "Choice One":
  21. trace("one");
  22. break;
  23. case "Choice Two":
  24. trace("two");
  25. break;
  26. }
  27. }

以上是关于AS3组合框“onSelect”更改的主要内容,如果未能解决你的问题,请参考以下文章

下拉 OnSelect 和 OnChange 操作未触发

ActionScript 3 AS3 ComboBox“onSelect”正在改变

AS3/Flash:组合框和文本输入交互

单击按钮时如何删除组合框组件 flash as3

AS3组合框非常基本的例子

as3 文本字段更改字符串值