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.