[Question] make the script run in every frame

Hello,

I have 2 navigation buttons (next and previous) that navigates to the next and previous frames.

acctually i have several buttons (differ by color) with the same instance name.

i have to add eventListener every time i reach a frame with a new button.

First question is why?
if all “next” buttons have the same instance name, why doesn’t it work on all of them?

second question:
i want to check whether there is an object in the current frame, how do i apply the code to all the frames (that will work on each frame) without dupplicating it.

stop();
import flash.events.MouseEvent;

if (pre_btn_insNm!==null){

pre_btn_insNm.addEventListener(MouseEvent.MOUSE_DOWN,gotoPreviousFrame);

}
if (next_btn_insNm!==null){
next_btn_insNm.addEventListener(MouseEvent.MOUSE_DOWN,gotoNextFrame);
}