Reference objects on multiple frames from .as file

I have a movie clip that has three frames, each frame contains unique objects that I would like to reference to, however, I am trying to reference the objects from an .as file for that movie clip, I find that I am able to reference the objects on frame 1 only, if I try to reference the objects on frame 2 or 3, I get an error stating the objects don’t exist, I found a way to fix this and that is to put the actual code inside of the frames, but I would much rather do this from the .as file, is there a way to do that