ArgumentError: Error #1063: Argument count mismatch on johnflash_fla::MainTimeline/en
Okay, I tried to run a flash document I made and got the following message in the output, with the only action visibly performed being the rotation of "ground":
I've asked people I know who know some programming what an argument is, but I don't see how it applies to my flash document. So I thought I'd ask the AS3 community what the problem is in my document. The document is attached, the code is below. "dude" is a blue block that is supposed to be affected by gravity, and "ground" is a line that "dude" is supposed to land on and slide down. So here's the code:
Code:
//make a variable that I can change to mess with different gravity-based acceleration. The variable "gravity" is made below, but I set the value at the top of the code for my convenience.
gravity = 10;
//make variables that affect the motion of the block
var gravity = new Number;
var speed = new Number;
var sideSpeed = new Number;
//give initial values to the variables. The block starts out static
speed = 0;
sideSpeed = 0;
//rotate "ground" 45 degrees
ground.rotation = 45;
//position "ground"
ground.x = 200;
ground.y = 200;
//event listener to make certain things happen every frame
stage.addEventListener(Event.ENTER_FRAME, enterFrame);
//function for what I want to happen every frame
function enterFrame():void {
y -= speed; //number of pixels/frame upwards = "speed" variable
x += sideSpeed; //number of pixels/frame leftwards = sideSpeed variable
if(dude.y >= dude.x - speed && dude.x >= 50 && dude.x <= 350) {
dude.y = dude.x;
sideSpeed -= (1/2) * speed;
speed = (1/2) * speed;
} // if the block is between the left and right bounds of "ground," and its y in the next frame will be the same as or more than the x in this frame, then make the block's y value equal to its x value (if the block's registry point will fall downward past "ground" in the next frame, then make the coordinates of its position fall on the linear equation of "ground," which means the block's registry point will be on the line). Also convert half of the negative upward speed (downward speed) to positive leftward speed.
if(!(dude.y = ground.y) || dude.x < 50 || dude.x > 350) {
speed -= gravity;
} //deceleration (pixels/frame/frame) relative to upwards direction = "gravity" variable if the block is not on the line of "ground."
if(dude.y == dude.x && dude.x >= 50 && dude.x <= 350) {
speed -= (1/2) * gravity;
sideSpeed += (1/2) * gravity;
} //if the block is on the line, half the gravity is converted to sideSpeed instead of negative speed.
}
whenever an event listener fires, it will pass an event object to the assigned function as a parameter. You'll need to set your enterFrame function to receive it...