Tuesday 15 February 2011

flash - Incorrect Number of Arguments, expected 2 -


I am doing this avoider game tutorial for my class to better understand actionscript, the game just ended , But it must be closed after the initial contact with the enemy. I'm getting an error saying "wrong number of error, expectation of 2" And this line is singing out of 13, which is enemy = newInemi (); Is it simple as a missing class? I will also post the square below

  Package {import flash.display.MovieClip; Import Flash. Import flash.events.TimerEvent; Public Square AvoiderGame Movie Clip (Public Prize Foe: Amy; Public Game Game Timer: Timer; Public Avatar: Avatar; Public Work AvoiderGame () {Enemy = New Enemy (); AddChild (Enemy); Avatar = New Avatar (); Child (avatar); Avatar.x = mouseX; Avatar.y = mouseY; GameTimer = New timer (25); GameTimer.addEventListener (TimerEviventTMER, Onic); gameTimer.start ();} Public function onTick (timerEvent: TimerEvent ): Zero {enemy.moveDownABit (); Avatar.x = mouseX; Avatar.y = mouseY; if (avatar.hitTestObject (enemy)) {gameTimer.stop ();}}}}   

class:

  package {import flash.display.movieclip; public class anime movieclip {public function anime (startX: number, starting number :) {x = StartX; Y = startY;} public function movesDownbyte (): zero {y = y + 3;}}  

Your enemy class has two parameters: startX and startY , so in this case, make an example of that class For what you have to do:

  var enemies: enemy = new enemy (value_of_startX) , Value_of_startY); Otherwise, the compiler will fire that error: "Wrong number of arguments, expected 2.".  

But if you want to make an example of your class without mentioning startX and startY , then you set some parameters like your parameters It can:

  // Your default value here is: 0, 0 public function animation (startX: number = 0, start: number = 0) {x = startX; Y = startY; }  

And then you can like it or you can call it without the ultimate.

Hope that can help.


No comments:

Post a Comment