Instantiation of a class of functions?

Hey all,

I’ve been coding a bunch of movie clips as buttons (gives me more flexibility) and the lines of code is phenomenal… :!:

I was wondering if i could create a template of functions, and instantiate it for each object?

Idea:

ActionScript Code:
[FONT=Courier New][LEFT]unimatic.[COLOR=#0000FF]onRollOver[/COLOR] = [COLOR=#000000]**function**[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
unimatic.[COLOR=#0000FF]gotoAndPlay[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]2[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000]}[/COLOR];

unimatic.[COLOR=#0000FF]onRollOut[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
unimatic.[COLOR=#0000FF]gotoAndStop[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#000000]}[/COLOR];

unimatic.[COLOR=#0000FF]onRelease[/COLOR] = [COLOR=#000000]function[/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]attatchTab[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]filename[/COLOR] = [COLOR=#FF0000]“unimatic.txt”[/COLOR];
[COLOR=#000000]}[/COLOR];
[/LEFT]
[/FONT]

basically, the text UNIMATIC is the instance name of clip in question and there are 15 clips on the stage. The .txt part also changes and matches the name of the instance name of the clip.

Is there anyway i can loop through that and generate the function code for several clips from this template instead of having to repeat an enourmous amount of code for each clip??

Thanks in advance!