Animation

I have an animation that has mask in it.
I’m using actionscript to set the mask.
The problem I am having is all the mask after frame 1 doesn’t work. When I trace the movie clip name it says null.
I know it’s because flash can’t access movie clip’s name because hasn’t loaded yet.

So the question is how do I do it?

I have the AS in a .as. I have tried putting the as on the first frame, same thing.

The only way I know to make it work is to add the AS on each of the key frame which will be a pain to do.