Flash Menu

I haven’t done anything in Flash for a while, I focused on PHP. But a customer wants some animation in Flash. So I’m creating a Flash menu on CS3 for the first time and I find out that it’s not as it used to be. So I look for a tutorial online on how to work with buttons. It tells me to name the button and do some programming to it:


homepage.addEventListener(MouseEvent.CLICK,goWhere)
function goWhere(evt)
{
	var url = "http://www.mydomain.com"
	navigateToURL(new URLRequest(url))
}

But now I want to create a lot of buttons since it’s a menu and I can’t use this custom function because it only works with ONE url. For a quick fix, I create a function per page, for example:


homepage.addEventListener(MouseEvent.CLICK,goWhere)
function goWhere(evt)
{
	var url = "http://www.mydomain.com"
	navigateToURL(new URLRequest(url))
}

page2.addEventListener(MouseEvent.CLICK,goWherePage2)
function goWhereHTT(evt)
{
	var url = "http://www.mydomain.com/page2.php"
	navigateToURL(new URLRequest(url))
}

page3.addEventListener(MouseEvent.CLICK,goWherePage3)
function goWhereProjects(evt)
{
	var url = "http://www.mydomain.com/page3.php"
	navigateToURL(new URLRequest(url))
}

I know there should be a way to make an if statement and simplify the code. This would be very useful since there is more than 3 pages.

Problem #2, the URL comes out in a new window, how can I make it come out in the same window?

Sorry, I do not know ActionScript, I just kinda figure out what the code means.