dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: ArgumentError: Error #1063: Argument count mismatch on johnflash_fla::MainTimeline/en

  1. #1
    Member
    Join Date
    Apr 2009
    Posts
    58

    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":

    ArgumentError: Error #1063: Argument count mismatch on johnflash_fla::MainTimeline/enterFrame(). Expected 0, got 1.

    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.
    }
    Again, the document is attached
    Attached Files Attached Files

  2. #2
    newb of many sorts Ralgoth's Avatar
    Join Date
    Apr 2002
    Posts
    466
    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...

    function enterFrame(event:Event):void {
    Search first, asked questions later.

  3. #3
    Member
    Join Date
    Apr 2009
    Posts
    58
    Hey, thank you so much for helping me out, then going the extra mile and explaining why it works the way it does.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center