views:

28

answers:

2

So this doesn't make any sense. I have actionscript in a flash-based button menu, and one of the buttons is linking to the wrong page, and i cannot figure out why. Here is the actionscript:

var myURL1:URLRequest = new URLRequest ("home.html");
home_btn.addEventListener(MouseEvent.CLICK, home_btnEventHandler);
function home_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL1, "_self");
}
var myURL2:URLRequest = new URLRequest ("featuredwork.html");
work_btn.addEventListener(MouseEvent.CLICK, work_btnEventHandler);
function work_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL2, "_self");
}
var myURL3:URLRequest = new URLRequest ("featuredartist.html");.
artist_btn.addEventListener(MouseEvent.CLICK, artist_btnEventHandler);
function artist_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL3, "_self");
}
var myURL4:URLRequest = new URLRequest ("artists.html");
members_btn.addEventListener(MouseEvent.CLICK, members_btnEventHandler);
function members_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL4, "_self");
}
var myURL5:URLRequest = new URLRequest ("events.html");
events_btn.addEventListener(MouseEvent.CLICK, events_btnEventHandler);
function events_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL5, "_self");
}
var myURL6:URLRequest = new URLRequest ("/blog/index.php");
blog_btn.addEventListener(MouseEvent.CLICK, events_btnEventHandler);
function blog_btnEventHandler(event:MouseEvent):void
{
    navigateToURL(myURL6, "_self");
}

Now, when I click on blog_btn, it is sending me to the "events" page. It makes no sense. Does anybody have any idea?

A: 

You've bound the events handler to the blog_btn click - change the last block to point to the correct handler:

blog_btn.addEventListener(MouseEvent.CLICK, blog_btnEventHandler);
Dexter
great thanks. cant believe i missed that.
A: 

Fairly easy to spot: you have

blog_btn.addEventListener(MouseEvent.CLICK, events_btnEventHandler);

when you mean

blog_btn.addEventListener(MouseEvent.CLICK, blog_btnEventHandler);

notice the second parameter.

Philip Rieck
great thanks. cant believe i missed that.