onEnterFrame in functions

Is there any way to perform a the contents of a function every frame? Take this code for a simple example:

function test(string) {
    this.onEnterFrame = function () {
        trace(string);
    }
}

Doesn’t work, anybody know a way that the same thing will work?