Be a Supporter!

AS3 expecting 0 elements

  • 282 Views
  • 6 Replies
New Topic Respond to this Topic
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
AS3 expecting 0 elements 2012-01-06 12:25:16 Reply

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.

23450
23450
  • Member since: May. 28, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Blank Slate
Response to AS3 expecting 0 elements 2012-01-06 12:48:26 Reply

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
caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to AS3 expecting 0 elements 2012-01-06 12:52:45 Reply

ive checked it twice, its correct.

caseymacneil
caseymacneil
  • Member since: Nov. 19, 2008
  • Offline.
Forum Stats
Member
Level 06
Programmer
Response to AS3 expecting 0 elements 2012-01-06 12:56:42 Reply

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

23450
23450
  • Member since: May. 28, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Blank Slate
Response to AS3 expecting 0 elements 2012-01-06 12:59:04 Reply

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
23450
23450
  • Member since: May. 28, 2003
  • Offline.
Forum Stats
Supporter
Level 27
Blank Slate
Response to AS3 expecting 0 elements 2012-01-06 13:00:05 Reply

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
UnknownFury
UnknownFury
  • Member since: Aug. 10, 2005
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to AS3 expecting 0 elements 2012-01-06 14:53:31 Reply

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.