Prova e fai sapere
// create an array and put the buttons in it
var buttons_array:Array=new Array(menu_mc.flep_mc,menu_mc.flash_mc,menu_mc.ps_ mc,menu_mc.news_mc,menu_mc.blog_mc);
//array che contiene tutti gli url associati ai pulsanti
var url_array:Array = ["http://www.onsitus.it", "http://www.flepstudio.org", "http://www.google.it", "http://www.yahoo.it", "http://www.libero.it"];
/* add listeners to buttons. Add an id for each button.
At MOUSE_DOWN calls "callSelectionButton" function*/
for(var i:int=0;i
{
buttons_array[i].mouseChildren=false;
buttons_array[i].buttonMode=true;
buttons_array[i].id=i;
buttons_array[i].addEventListener(MouseEvent.MOUSE_DOWN,callSelect ionButton);
}
/* This function calls another funtion ( selectionButton )
passing the id of the button that has been clicked*/
function callSelectionButton(evt:MouseEvent):void
{
selectionButton(evt.target.id);
//URLRequest
var url:URLRequest = new URLRequest(url_array[evt.target.id]);
navigateToURL(url, "_self");
}
/* create the function that handle the states of buttons.
This function requires one paremeter ( int type ) that is the id of the selected button*/
function selectionButton(id:int):void
{
// open a loop through the buttons array
for(var i:int=0;i
{
if(i==id)
buttons_array[i].gotoAndStop(1);
else
buttons_array[i].gotoAndStop(2);
}
}
// Enable the first button
selectionButton(0);