Simple general Timer?

Hi, having spent many hours, with books :book: and the web I’d like to ask for your help with a bit of code that wont run as I want it to.

The code is a simple Timer function, that works when I use it directly on the main timeline, but for the life of me I cannot get it to work as a class. I wish to have it as a standalone Timer class that I call when ever I want to have a delay (and ideally send it the delay). At the moment it wont even run with trace statements in the functions. The following is the code that works when on the main time line.

//start of Timer script

var delay:Number = 87;
var timer:Timer; // sets up a new Timer variable.

function myTimer()
{
timer = new Timer(delay, 10); // sets up a new Timer instance with a delay of 87 ms and how many repetitions (0 = continuous loop)

timer.addEventListener(TimerEvent.TIMER, onTimer); // adds a listener to the Timer and runs the function when the Timer starts

timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); // this listens for when the Timer is complete (i.e. when the second number has been reached)

timer.start(); // this starts the timer running.

trace(“inside timer”);
}

function onTimer(event:TimerEvent):void
{
trace(“tick”);
}

function onTimerComplete(event:TimerEvent):void
{
trace(“Finished!”);
}

myTimer(); // runs the myTimer function’

// end of script

the above all works fine.

But when trying to use as a class it gives the following error…

"TypeError: Error #1034: Type Coercion failed: cannot convert 87 to generalTimer. "

I have tried various types (Number, int, String) and it still says the samething.

Here’s my class file…

// class file

package
{
//trace(“called as file”);
import flash.display.Sprite;
import flash.utils.;
import flash.events.
;
public class generalTimer extends Sprite
{
//public static const w:Number = 10 * 1000;
public var timer:Timer;
trace(“inside timer class”);

public function generalTimer(w:Number)
{
timer = new Timer(w, 10);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
timer.start();
trace(“inside timer”);
}

private function onTimer(event:TimerEvent):void
{
trace(“tick”);
}

private function onTimerComplete(event:TimerEvent):void
{
trace(“Finished!”);
}
}
}

// end of class file

In the .fla file i have the following…

// start of .fla file
var w:Number = 87;
generalTimer(w);
// end of .fla file

why cant I send it a number to act on as it does inside my .fla file or like arguments sent to a function?

Also even when testing it with the code as a standalone class as follows, it doesn’t do anything?

//
public class generalTimer extends Sprite
{
public static const w:Number = 10 * 1000;
public var timer:Timer;
trace(“inside timer class”);

public function generalTimer()
{
timer = new Timer(w, 10);
//

I’ve tried ‘generalTimer;’ which doesn’t do anything. I’ve tried ‘generalTimer();’ which gives me ‘too many arguments’ error.

Im eventually looking to have it return something(not sure yet) when the ‘onTimerComplete’ event happens too, but that’ll be my next problem.

Please help as all logic has gone out the window it seems. ;(

Thanks in advance.

Trev.