Be a Supporter!

[as3] timer problem

  • 443 Views
  • 5 Replies
New Topic Respond to this Topic
stickman8190
stickman8190
  • Member since: Mar. 7, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
[as3] timer problem 2012-06-08 15:51:34 Reply

I'm trying to make a timer which I got from here this is the error I get when I try to test it

Scene 1, Layer 'actions', Frame 1, Line 7 1136: Incorrect number of arguments. Expected 0.

But I don't know how to fix it, any help please? and this is the code

import flash.utils.Timer;
import flash.events.TimerEvent;
var yy:Number=0; //(STARTING) Y POSITION OF LINE

//Fisrt value is number of microseconds between timer events
// second value is number of times to run timer event - 0=infinite
var DTimer:Timer = new Timer(33,0);
DTimer.addEventListener(TimerEvent.TIMER, DRAWLINE); //add the timer event

function DRAWLINE(event:TimerEvent):void{
	trace("drawing line");
	graphics.lineStyle(3,0xff0000,1); //be aware alpha range is now 0-1 not 0-100
	graphics.moveTo(0,yy); //move to left
	graphics.lineTo (stage.stageWidth,yy); //Stage.width is now stage.stageWidth
	yy+=30; //move downwards
	if(yy>stage.stageHeight){ //reached bottom of stage
		DTimer.stop(); //stop the timer event
	}
}

DTimer.start(); //run the timer

also click Here to view my profile at jiggmin.com

BBS Signature
Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to [as3] timer problem 2012-06-08 16:03:26 Reply

Your code works absolutely fine for me, the error must be elsewhere. Is that the code on frame 1?

stickman8190
stickman8190
  • Member since: Mar. 7, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to [as3] timer problem 2012-06-08 16:13:19 Reply

At 6/8/12 04:03 PM, Sam wrote: Your code works absolutely fine for me, the error must be elsewhere. Is that the code on frame 1?

Well yes I put the code on frame 1, is it wrong to be on frame 1?


also click Here to view my profile at jiggmin.com

BBS Signature
Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to [as3] timer problem 2012-06-08 16:15:14 Reply

At 6/8/12 04:13 PM, stickman8190 wrote:
At 6/8/12 04:03 PM, Sam wrote: Your code works absolutely fine for me, the error must be elsewhere. Is that the code on frame 1?
Well yes I put the code on frame 1, is it wrong to be on frame 1?

Not particularly wrong, however, programming in classes is much more organised and seen as a more professional way to program in AS3.

That's besides the point. Copy the code you posted into a new AS3 document and see if it works. I had no problems at all running that section of your code.

stickman8190
stickman8190
  • Member since: Mar. 7, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to [as3] timer problem 2012-06-08 16:43:44 Reply

never mind, i fixed it, the problem was that i created a dynamic text and exported it for actionscript, and i wasn't suppose to do that, but thanks for trying to help


also click Here to view my profile at jiggmin.com

BBS Signature
Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to [as3] timer problem 2012-06-08 16:48:09 Reply

At 6/8/12 04:43 PM, stickman8190 wrote: never mind, i fixed it, the problem was that i created a dynamic text and exported it for actionscript, and i wasn't suppose to do that, but thanks for trying to help
At 6/8/12 04:03 PM, Sam wrote: the error must be elsewhere.

No problem, glad you fixed it.