Running functions

I know how to write and use a function, but the problem is that it is only rn once. e.g.

[AS]
function runningAllTheWay(){
//code
}
[/AS]

I want it to have an onEnterFrame property but with the usage of the normal function. somthing like

[AS]
function somethingLike(){
onEnterFrame = function(){
//run code for 20 frames
}
}
[/AS]

Problem is that I dont know how to write this properly, if some one could help it would be greatly appreciated.