Q:

Button Hyperlinking in Animate ActionScript 3.0

I'm trying to make three buttons in Adobe Animate, using ActionScript. Here is the code I'm using for button 1:
button. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
     navigateToURL(new
     URLRequest("https://website.com/"));
}

button2. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler2(event:MouseEvent):void {
     navigateToURL(new
     URLRequest("https://anotherwebsite.com/"));
}

button3. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler3(event:MouseEvent):void {
     navigateToURL(new
     URLRequest("https://yetanotherwebsite.com/"));
}

(The URLs are made up and only for demonstration purposes.) The code for button 2 and 3, as you can see, are exactly the same but on different layers. I also change the instance name at the start, the function name, and the URL for each button. But when I press CTRL + Enter, all the buttons lead to the same webpage (in this case "website.com"), which is the one I put in first. It should lead to the different URLs I put in, but they all just go to the same one. Why is this happening and how do I fix this?

A:

The problem is, although you've defined 3 separate handler functions for the 3 separate buttons, you are attaching the first handler function to all 3 buttons:
button. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
button2. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
button3. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

What you mean to do is this:
button. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
button2. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler2);
button3. addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler3);

Though, as an aside, you could do it all with one handler function using the event's current target parameter to figure which button was clicked:
function mouseDownHandler(event:Event):void {
    var url:String;
    //event.currentTarget is a reference to the object that you attached the event listener to
    switch(event.currentTarget){
        case button:
            url = "https://website.com/";
            break;

        case button2:
            url = "https://anotherwebsite.com/";
            break;

        default:
            url = "https://yetanotherwebsite.com/";
    }

    navigateToURL(new URLRequest(url));
}

