简体   繁体   English

actionscript 代码中的错误:1000(对按钮的模糊引用)

[英]Error in actionscript code: 1000(Ambiguous reference to Button)

I have a Button Component on my Stage.我的舞台上有一个按钮组件。

When I go to compile I get the following error.当我 go 编译时,出现以下错误。

1000(Ambiguous reference to Button)

Cant seem to find what is wrong here.似乎无法在这里找到问题所在。

You probably have more than one class with the name Button in your library or in your classpath.您的库或类路径中可能有不止一个 class 名称为Button The compiler doesn't know which one you want to use and hence the error.编译器不知道您要使用哪一个,因此不知道错误。 Sometimes it helps to provide the full package name like this:有时提供完整的 package 名称会有所帮助,如下所示:

var button:com.whatever.buttons.Button = button1;

But it's hard to tell if you're not providing some more code.但是很难判断您是否没有提供更多代码。

I just experienced this issue too.我也刚遇到这个问题。 I tried declaring the package along with the variable type, but it didn't help.我尝试将 package 与变量类型一起声明,但没有帮助。 What ended up being the problem was that I had added an mx button while in design mode, but in the script I was declaring a spark.components.button.最终的问题是我在设计模式下添加了一个 mx 按钮,但在脚本中我声明了一个 spark.components.button。 Once I switched the button type from design mode, it fixed to problem.一旦我从设计模式切换按钮类型,它就解决了问题。

            for each (var player:XML in rosterFile.player){

                        ...

                var plusB:Button = new Button();
                plusB.id = "plus" + count.toString();
                plusB.x = 286;
                if(count == 0){
                    plusB.y = 37;
                }else{
                    plusB.y = (37 + (count * 64));
                }
                plusB.label = "+";
                arena.addElement(plusB);

                count++;
            }

Just for posterity, also consider whether you are mixing access modifiers.只是为了后代,还要考虑您是否混合了访问修饰符。 For example, on a getter and setter method:例如,在 getter 和 setter 方法上:

public set myVar(a:String):void {
  _a = a;
}

private get myVar():String {
  return _a;
}

public function test():void {
  trace(a); // throws error, though it may not seem obvious why
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM