DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Kalatravas has posted 29 posts at DZone. View Full User Profile

Manipulating The ComboBox In Flash CS3

09.26.2010
| 3097 views |
  • submit to reddit
        More info at http://www.tournasdimitrios1.wordpress.com

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

var arr:Array = [{label:"In.gr" , data:"http://www.in.gr"} ,
				 { label:"Amazon.com" , data:"http://www.amazon.com"} ,
				 {  label:"Yahoo.com" , data:"http://www.yahoo.com"}];

var inf:DataProvider = new DataProvider(arr);
var myco:ComboBox = new ComboBox();
addChild(myco);
myco.dataProvider = inf;
myco.prompt = "Select a website";
myco.width = 120;
myco.selectedIndex = -1;
myco.addEventListener(Event.CHANGE , gotoUrl);

function gotoUrl(e:Event):void {
	var num:Number = e.target.selectedIndex;
	trace(num);

	var request:URLRequest = new URLRequest();
    request.url = ComboBox(e.target).selectedItem.data;
    navigateToURL(request);

}