views:

24

answers:

2

I have a couple timers in a Flash application I'm building. They worked fine initially, but after building the application and adding more code to it, I'm suddenly getting these weird compiler errors. When I try to compile, I get 'error 1136: Incorrect number of arguments. Expected 0.' on the line of the Timer declaration, which looks like this:

var newTimer:Timer = new Timer(5000, 1);

I've tried declaring without arguments and adding them to the according properties like this:

var newTimer:Timer = new Timer();
newTimer.delay = 5000;
newTimer.repeatCount = 1;

When I do this I get 'error 1120: Access of undefined property newTimer.' on both of the delay and repeatCount lines. Any ideas as to what the problem could be?

A: 

var newTimer:Timer = new Timer(5000, 1);

Theo.T
My mistake. That is how I declared the timers in my script I just wrote it wrong above. I've corrected the errors.
pythonBOI
ha, sure. however your code is ok, so must be a typo. I'm pretty sure you forgot the space between 'new' and 'Timer' or something likely. The naming you are using is misleading. You should maybe paste the whole code block, the statement just before the line can be the issue as well ...
Theo.T
What was so weird was that my code compiled fine the first few dozen times I compiled and then all of a sudden started showing errors, so I had a feeling that the problem wasn't with my declarations or any nearby code. Turns out that the problem was caused by a movieclip object I created called...'Timer'. CRAP. Oh well, thanks for your suggestions Theo.
pythonBOI
A: 

Timer accepts two arguments so that "expecting 0" error is suspicious. Are you by chance exporting another MovieClip or object with a class name of "Timer"?

Typeoneerror
Bingo. Don't know how I missed something so simple. Thanks for the help.
pythonBOI
It's always the simple stuff. Glad to help. :)
Typeoneerror