You can put a function inside an empty movie clip (then it does not need to be a function anymore), that loops when you play it. When you dont want it, you just stop playing that movie.