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.
// this code assumes the existance of a ComboBox (Components -> User Interface -> ComboBox) // on the stage with an instance name of "MY_DROPDOWN_INSTANCE_NAME" plus two items defined in its properties // named "Choice One" and "Choice Two" var MY_DROPDOWN_LISTENER:Object=new Object(); // a new listener MY_DROPDOWN_INSTANCE_NAME.addEventListener("change", MY_DROPDOWN_LISTENER); //add listener to combobox MY_DROPDOWN_LISTENER.change=function(){ //function called // do something based on the selected item's label switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().label) { case "Choice One": trace("one"); break; case "Choice Two": trace("two"); break; } // do something based on the selected item's value switch(MY_DROPDOWN_INSTANCE_NAME.getSelectedItem().data) { case "Choice One": trace("one"); break; case "Choice Two": trace("two"); break; } }
以上是关于AS3组合框“onSelect”更改的主要内容,如果未能解决你的问题,请参考以下文章