ActionScript 3 AS3 ComboBox极其基本的例子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3 ComboBox极其基本的例子相关的知识,希望对你有一定的参考价值。

package {
	import flash.display.MovieClip;
	import flash.events.Event;

	import fl.events.ComponentEvent; 
	import fl.controls.ComboBox;
	import fl.data.DataProvider; 




	public class AS3_combobox2 extends MovieClip {
		var comboData:Array = new Array( 
			{label:"Choice One", data:"one"}, 
			{label:"Choice Two", data:"two"}
		); 
		
		var combobox_cb:ComboBox = new ComboBox();

		public function AS3_combobox2() {
			combobox_cb.dropdownWidth = 210; 
			combobox_cb.width = 200;  
			combobox_cb.move(150, 50); 
			combobox_cb.prompt = "Make a Choice"; 
			combobox_cb.dataProvider = new DataProvider(comboData); 
			combobox_cb.addEventListener(Event.CHANGE, changeHandler); 
			 
			addChild(combobox_cb); 
		}
		public function changeHandler(event:Event):void { 
			// do something based on the selected item's value
			switch(combobox_cb.selectedItem.data) {
				case "one":
					trace("One was chosen!");
					break;
				case "two":
					trace("Two was chosen!");
					break;
			}
		}




	}
}

以上是关于ActionScript 3 AS3 ComboBox极其基本的例子的主要内容,如果未能解决你的问题,请参考以下文章

[ActionScript 3.0] AS3.0 水面波纹效果

ActionScript 3 AS3:使用SWFObject2和AS3传递变量

ActionScript 3 克隆数组(AS3)

ActionScript 3 AS3序列化

ActionScript 3 As3初始上限

ActionScript 3 AS3 HTML清理