00:00
00:00
Newgrounds Background Image Theme

N0vasu just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

AS3 expecting 0 elements

569 Views | 6 Replies
New Topic Respond to this Topic

AS3 expecting 0 elements 2012-01-06 12:25:16


i asked for help on this a while ago and no one could figure out the problem and they kept ignoring the subject and ranting on about random shit, so i decided to ask again, in my player class it reads this

public class Player extends MovieClip
	{
		
		public function Player(X:Number,Y:Number)
		{
			// constructor code
			x = X
			y = Y
			
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, keyUp);
		}
       }

and in the main doc class it makes a new player like so

private var _player:Player = new Player(400,300)

and then i get this error saying

C:\Users\Casey\Dropbox\IDEProjects\mp201201\src\Main.as, Line 13	1136: Incorrect number of arguments.  Expected 0.

this only happens when im using the flash IDE, i never get the error when im just using flashdevelop alone.

Response to AS3 expecting 0 elements 2012-01-06 12:48:26


Make sure you are importing the correct class explicitly, and this its package is composed correctly.

In the flash IDE, in the properties of the movieclip, you may have specified its class as Player. If this reference does not directly point to the Player class path you have constructed, flash IDE creates a no-args constructor for it. So make sure this path is correct as well.


BBS Signature

Response to AS3 expecting 0 elements 2012-01-06 12:52:45


ive checked it twice, its correct.

Response to AS3 expecting 0 elements 2012-01-06 12:56:42


nvm fixed it, forgot you had to set the path in flash also. my bad.

Response to AS3 expecting 0 elements 2012-01-06 12:59:04


At 1/6/12 12:52 PM, caseymacneil wrote: ive checked it twice, its correct.

Is it at all possible for you to post the source of the project by email or otherwise? There is something funky going on with your configuration, and its hard to help from just looking at the player class.


BBS Signature

Response to AS3 expecting 0 elements 2012-01-06 13:00:05


At 1/6/12 12:56 PM, caseymacneil wrote: nvm fixed it, forgot you had to set the path in flash also. my bad.

Ah. Well, good luck continuing the project then.


BBS Signature

Response to AS3 expecting 0 elements 2012-01-06 14:53:31


Where's your definition of keyDown and keyUp? Sounds like one of them is expecting 0 arguements, when it should have one (a KeyboardEvent). Use the debugger to find which line of Player.as is causing the actual problem, but I guess it's one of those 2.

Also you'll have problems trying to add listeners to stage in the constructor as when you construct the class it doesn't know what stage is until you do addChild.