The code you have written for all the buttons run as soon as you start playing, but the button that the code is trying to access, does not exist at that point. So one way to fix this would be to keep each of the buttons off screen at the start. Another way to solve it would be to execute the code once all buttons are on the screen, but I would recommend the first solution.
Also, here's one way you could write the code, to make it a lot less repetetive:
function CreateButton (_button : DisplayObject, _animation : MovieClip) {
var over : Function = function () {
_animation.gotoAndPlay("animate");
}
var out : Function = function () {
_animation.gotoAndStop(1);
}
_button.addEventListener(MouseEvent.MOUSE_OVER, over);
_button.addEventListener(MouseEvent.MOUSE_OUT, out);
}
CreateButton(subMenuStatic_mc.glass_btn, this.glassdept_mc);
CreateButton(subMenuAnimate_btn.glass_btn2, this.glassdept_mc);
That way you only have to write one line of code for each new button you want to add. And if you want to change the behaviours of the buttons, you only need to change it inside the CreateButton function, instead of on multiple different lines of code.