My code gets an argument error, expecting 1 but got 0 - AS3

Posted by Louis Cottier on Stack Overflow See other posts from Stack Overflow or by Louis Cottier
Published on 2013-10-23T03:39:27Z Indexed on 2013/10/23 3:53 UTC
Read the original article Hit count: 194

Filed under:
|
|

I've got this code with a variable of platform, which I'm trying to link with the actual object of Platform in my .fla file but I get this error when I run it; ArgumentError: Error #1063: Argument count mismatch on Code(). Expected 1, got 0. In my output window.

package  {

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.ui.Keyboard;


public class Code extends MovieClip {

    var charSpeed:int = 0;
    var velocity:int = 0;
    var gravity:Number = 1;
    var Jump:Boolean = false;


    public function startGame(){
         stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);
         stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
         stage.addEventListener(Event.ENTER_FRAME, loop);
     }

    private var platform:Platform;

    public function Code(value:Platform) {
        platform = value;
    }

    function checkKeyDown(evt:KeyboardEvent){
        if (evt.keyCode == Keyboard.LEFT){
            charSpeed -= 10;
        }
        if (evt.keyCode == Keyboard.RIGHT){
            charSpeed += 10;
        }
        if (evt.keyCode == Keyboard.DOWN){
            if(!Jump){
                velocity -= 14;
                Jump = true;
            }
        }
    }

    function checkKeyUp(evt:KeyboardEvent){
        if (evt.keyCode == Keyboard.LEFT){
            charSpeed = 0;
        }
        if (evt.keyCode == Keyboard.RIGHT){
            charSpeed = 0;
        }
    }

    function loop(evt:Event){
        player.x = velocity;
        if (player.x < 0){
             player.x = 0;
        }
        if (player.x > 550){
             player.x = 550;
        }

        velocity += gravity;

        var Platform:Array = new Array(platform)


        if (!Platform.hitTestPoint(player.x, player.y, true)){
            player.y += velocity;
        }

        for (var i = 0; i < 10; i++){
            if (Platform.hitTestPoint(player.x, player.y, true)){
                player.y--;
                velocity = 0;
                Jump = false;
            }
        }
    }
}

}

The as3 file name is Code, and the fla file name is Game. My objective is to get my player to move around on the platform using the arrow keys. The linkage of my platform is "Platform". If anyone could help that would be great

© Stack Overflow or respective owner

Related posts about actionscript-3

Related posts about flash