AS3参数错误#1063,期望1得到0。

时间:2022-10-28 04:52:53

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:

在坐标系1中的一个物体:

var teste:XmlLang = new XmlLang(1);

I'm getting this error:

我得到这个错误:

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

错误#1063:在XmlLang()上的参数不匹配。预计1,0

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

我做错了什么?非常感谢你的帮助。

3 个解决方案

#1


1  

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.

这是我所做的。我创建了一个新的测试。在AS3中的fla文件并将下面的代码放在框架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

创建了一个XmlLang。作为文件,完全复制您的代码并将其保存在与test.fla相同的文件夹中。编译并得到1的跟踪。

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

所以我不确定到底发生了什么。你正在运行什么版本的Flash ?

#2


1  

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.

不确定这是不是你的情况,但是对于未来的googlers:当你试图初始化一个向量但却忘记了新的关键字时,你会得到这个错误信息。

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.

看一眼就有困难。我花了几分钟在代码中找到它,特别是因为它并没有给出错误的代码。

#3


0  

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:

我希望您有一个位于舞台上的XmlLang实例,它将使用一个带有0个参数的构造函数来构造,就像一个普通的MovieClip。要检查此情况,请将构造函数标题更改为:

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.

这样,如果某样东西在没有提供参数的情况下实例化了一个XmlLang,新实例将接收一个0(默认值)作为参数。然后你检查你的跟踪输出,我期待一个或多个零出现,然后是1。

#1


1  

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.

这是我所做的。我创建了一个新的测试。在AS3中的fla文件并将下面的代码放在框架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

创建了一个XmlLang。作为文件,完全复制您的代码并将其保存在与test.fla相同的文件夹中。编译并得到1的跟踪。

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

所以我不确定到底发生了什么。你正在运行什么版本的Flash ?

#2


1  

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.

不确定这是不是你的情况,但是对于未来的googlers:当你试图初始化一个向量但却忘记了新的关键字时,你会得到这个错误信息。

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.

看一眼就有困难。我花了几分钟在代码中找到它,特别是因为它并没有给出错误的代码。

#3


0  

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:

我希望您有一个位于舞台上的XmlLang实例,它将使用一个带有0个参数的构造函数来构造,就像一个普通的MovieClip。要检查此情况,请将构造函数标题更改为:

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.

这样,如果某样东西在没有提供参数的情况下实例化了一个XmlLang,新实例将接收一个0(默认值)作为参数。然后你检查你的跟踪输出,我期待一个或多个零出现,然后是1。