ComboBox Component Tutorial

Published :
Author :
Adam Khoury
In this Flash ActionScript 3.0 tutorial we show a dynamic example of how to populate drop down lists according to user selection. We show you how to access the value of what the user has chosen, and also how to clear a comboBox component of all of its list items. function carList():void { cb1.addItem( { label: "Ford Mustang" } ); cb1.addItem( { label: "Porsche 911" } ); cb1.addItem( { label: "Dodge Viper" } ); } function jacketList():void { cb1.addItem( { label: "Leather" } ); cb1.addItem( { label: "Sheepskin" } ); cb1.addItem( { label: "Wool" } ); } function carsBtnClick (event:MouseEvent):void { cb1.removeAll(); carList(); status_txt.text = "You clicked on the Cars button"; } function jacketsBtnClick (event:MouseEvent):void { cb1.removeAll(); jacketList(); status_txt.text = "You clicked on the Jackets button"; } cars_btn.addEventListener(MouseEvent.CLICK, carsBtnClick); jackets_btn.addEventListener(MouseEvent.CLICK, jacketsBtnClick); cb1.addEventListener(Event.CHANGE, displaySelection); function displaySelection (event:Event):void { status_txt.text = "You chose: " + cb1.selectedItem.label; }