# Timeline scripts - best practice

**URL:** <https://forum.kirupa.com/t/timeline-scripts-best-practice/249659>\
**Category:** flash\
**Created:** [January 21, 2008, 2:04pm UTC](https://forum.kirupa.com/t/timeline-scripts-best-practice/249659 "2008-01-21T14:04:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabee77](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@sabee77](https://forum.kirupa.com/u/sabee77)\
**Post date:** [January 21, 2008, 2:04pm UTC](https://forum.kirupa.com/t/timeline-scripts-best-practice/249659/1 "2008-01-21T14:04:52Z")

</div>

Hi there,

I’d like to know what is the best practice for actions I want to execute when reaching frames on the Timeline.  
Is it better to not have any script and to write an enter-frame listener inside the document class?

For example, I have movieclip “mcBall” on frame 10, and I’m on frame 1. In the document class I set an MouseEvent.CLICK listener for the button:

function ClickBtn(event:MouseEvent){  
gotoAndStop(10);  
mcBall.init();  
}

It does not work as I have to be first on frame 10 and enter that frame before being able to access the init() function from “mcBall”. So I am forced to put a script on frame 10:

mcBall.init();

What is the workaround for that kind of situation? To have a constant enterFrame listener on the document class checking the frame number we are on? Would that not slow down the movie?

Thanks for your help.  
Seb.
