Return to Snippet

Revision: 22960
at January 26, 2010 17:03 by Winkyboy

Initial Code
package {
	import flash.display.MovieClip;

	import fl.controls.ComboBox;

	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); 
		public function changeHandler(event:Event):void { 
			// do something based on the selected item's value
			switch( {
				case "one":
					trace("One was chosen!");
				case "two":
					trace("Two was chosen!");


Initial URL

Initial Description
This is the most simple example of a ComboBox created in AS3, based mostly on Adobe's example from

Inside the zip file you will find two folders. The first is this example with a ComboBox dragged onto the stage of the FLA with a supporting .AS file to populate it and make it work. The second example shows a ComboBox created and populated entirely by actionscript.

Initial Title
AS3 ComboBox extremely basic example

Initial Tags
form, dropdown

Initial Language
ActionScript 3