[Question] make the script run in every frame


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.

import flash.events.MouseEvent;

if (pre_btn_insNm!==null){


if (next_btn_insNm!==null){