I have received the error 1136: incorrect huber of arguments. Expected 1. On Frame 1 Line 12+13.
I can not find anything wrong with it, but I am a big noob at AS3, so please be simple with replays.
Here is my code:
stop()
var leftDown:Boolean = false;
var rightDown:Boolean = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
addEventListener(Event.ENTER_FRAME, gameLoop);
function gameLoop(event:Event):void{
moveCharacter();
keyPressed(); //error here
keyReleased(); //error here
gravity();
}
function gravity()
{
if (character.y < (stage.stageHeight - character.height)){
if (testfloor.hitTestPoint (character.x, character.y, true))
character.y += 5;
}
}
function moveCharacter
(){
if (leftDown)
{
wall.x += 4;
}
if (rightDown)
{
wall.x -= 4;
}
}
function keyPressed (event:KeyboardEvent)
{
switch (event.keyCode)
{
case Keyboard.LEFT:
{
leftDown = true;
break;
}
case Keyboard.RIGHT:
{
rightDown = true;
break;
}
}
}
function keyReleased (event:KeyboardEvent)
{
switch (event.keyCode)
{
case Keyboard.LEFT:
{
leftDown = false;
break;
}
case Keyboard.RIGHT:
{
rightDown = false;
break;
}
}
}
Once again good luck and best of wishes, on finding this troublesome error.
error 1136: incorrect number of arguments. Expected 1
This one should be obvious. You are calling a function which is defined with one argument:
function keyPressed (event:KeyboardEvent)
You are calling it with out passing any arguments to it:
keyPressed();
This is why it's complaining! Same goes for keyReleased.
So basically either pass it a KeyboardEvent as you defined, or don't call this function at all. Your listener object will take care of it anyway. :)