How to make 4 "go to frame and play" buttons to work on the same frame?
Hello, i've been trying to make 4 buttons, each on their own separate layer to work, with the code being on the same frame. Here is the code:
import flash.display.MovieClip;
import flash.display.SimpleButton;
var layer:MovieClip = getChildByName("rock_button_layer") as MovieClip;
var button:SimpleButton = layer.getChildByName("Rock_button1") as SimpleButton;
button.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void
{
gotoAndPlay(1877);
}
import flash.display.MovieClip;
import flash.display.SimpleButton;
var layer:MovieClip = getChildByName("devil_button_layer") as MovieClip;
var button:SimpleButton = layer.getChildByName("devil_button") as SimpleButton;
button.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void
{
gotoAndPlay(2000);
}
import flash.display.MovieClip;
import flash.display.SimpleButton;
var layer:MovieClip = getChildByName("angel_button_layer") as MovieClip;
var button:SimpleButton = layer.getChildByName("angel_button") as SimpleButton;
button.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void
{
gotoAndPlay(2050);
}
import flash.display.MovieClip;
import flash.display.SimpleButton;
var layer:MovieClip = getChildByName("glut_button_layer") as MovieClip;
var button:SimpleButton = layer.getChildByName("glut_button") as SimpleButton;
button.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(event:MouseEvent):void
{
gotoAndPlay(2100);
}
When I test it, I get this error:


I'm a newbie when it comse to coding, but this is an animation for my college work and I'd really like it to work. I hope someone can tell me what i'm doing wrong, thank you.
