obinoob
obinoob

Reputation: 657

AS3 Argument Error #1063 ... expected 1 got 0

So I got a very basic class

package  {

    import flash.display.MovieClip;

    public class XmlLang extends MovieClip {

        public function XmlLang(num:int) {
            trace(num);
        }
    }
}

and an object at frame one:

var teste:XmlLang = new XmlLang(1);

I'm getting this error:

ArgumentError: Error #1063: Argument count mismatch on XmlLang(). Expected 1, got 0

What am I doing wrong? Thank you very much for you help.

Upvotes: 0

Views: 1777

Answers (3)

zeh
zeh

Reputation: 10659

Not sure if this was your case, but for future googlers: you get this error message when you're trying to initialize a vector but then forget the new keyword.

So this:

var something:Vector.<Something> = Vector.<Something>();

Will give you an error saying that Something had an argument count mismatch. The correct line is:

var something:Vector.<Something> = new Vector.<Something>();

Difficult error to get at a glance. Took me a few minutes to find it in my code, especially because it doesn't really give you the error line.

Upvotes: 1

Vesper
Vesper

Reputation: 18747

I expect you have an instance of XmlLang located on stage, that will be constructed using a constructor with 0 parameters, like an ordinary MovieClip. To check for this, change the constructor header to this:

public function XmlLang(num:int = 0) {

This way, if something will instantiate an XmlLang without a parameter supplied, the new instance will receive a 0 (the default value) as parameter. And then you check your trace output, I am expecting one or more zeroes appear, followed by an 1.

Upvotes: 0

Gone3d
Gone3d

Reputation: 1189

Something is up with your setup. I took your code and implemented it and it worked.

Here's what I did. I created a new test.fla file in AS3 and put the following code on frame 1 - no object on the stage, just code in frame 1.

import XmlLang;

var teste:XmlLang = new XmlLang(1);
stop();

Created a XmlLang.as file, copying your code exactly and saved it in the same folder as the test.fla. Compiled and got a trace of 1

So I'm not exactly sure what's going on. What version of Flash are you running?

Upvotes: 1

Related Questions