# How do I run a function when my program starts?

**URL:** https://forum.kirupa.com/t/how-do-i-run-a-function-when-my-program-starts/298596
**Category:** flash
**Created:** [October 21, 2009, 5:38pm UTC](https://forum.kirupa.com/t/how-do-i-run-a-function-when-my-program-starts/298596 "2009-10-21T17:38:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![qhrome27](https://avatars.discourse-cdn.com/v4/letter/q/f04885/32.png) [@qhrome27](https://forum.kirupa.com/u/qhrome27)
#### Post date: [October 21, 2009, 5:38pm UTC](https://forum.kirupa.com/t/how-do-i-run-a-function-when-my-program-starts/298596/1 "2009-10-21T17:38:48Z")

</div>

Hello,

I am totally new to AS3.0 and OOP in general, so this is a very basic question I can’t seem to figure out.

I have a package.

Inside that package is a class.

Inside that class is a function that initializes a timer called setTimer()

I am trying to run setTimer() when the program starts, but it seems that wherever I put the line setTimer(); in the program, I get an error.

How and where can I run this function just once when the program starts, so I can initialize my timer?

Thanks.
