ComboBox - acts like jumpMenu dropdown box
This is a ComboBox (drop down list) component which you can add to your swf to provide navigation. Javascript is used to do the nav (seems to work best across multiple browsers).
NOTE! You need to DRAG&DROP an instance of the combo box onto your stage. This puts the required files in the (automagically created) Component Assets folder. After you put it on the stage, you can delete the instance (the files in the Component Assets folder will remain).
//-----------------------------------------------------------------------------
private function add_nav_drop_down_list():void
{
var myFormat:TextFormat = new TextFormat();
myFormat.font = "Arial";
myFormat.color = 0xFFFF;
myFormat.size = 11;
myFormat.align = "left";
var myComboBox:ComboBox = new ComboBox();
myComboBox.prompt = "Navigation";
myComboBox.addItem( { label:"Homepage"} );
myComboBox.addItem( { label:"Sitemap" } );
myComboBox.addItem( { label:"Another Page" } );
myComboBox.textField.setStyle("textFormat", myFormat);
myComboBox.width = 160;
myComboBox.move(10, 260);
addChild(myComboBox);
//listener for navigation
myComboBox.addEventListener(Event.CHANGE, navigation);
}
//-----------------------------------------------------------------------------
private function navigation(e:Event):void
{
var holdUrl:String;
var myJump:String = e.target.selectedItem.label;
//nav based on combobox text
switch (myJump)
{
case "Homepage":
holdUrl = "home.htm";
break;
case "Sitemap":
holdUrl = "sitemap.php";
break;
default:
holdUrl = "nonav";
trace("Navigation not implemented yet");
}
if (holdUrl != "Navigation")
{
//go to url
//import flash.external.ExternalInterface REQUIRED
ExternalInterface.call("function(){location.href = '" + holdUrl + "';}")
}
}
//-----------------------------------------------------------------------------
Copyright Gary Rosenzweig
