澳门新葡亰信誉平台游戏Flex_ActionScript3.0——编译错误

by admin on 2020年1月23日
代码 消息 说明
  1000 Ambiguous reference to %s. 引用可能指向多项。例如,以下示例使用 rssxml 命名空间,每个命名空间都为 hello() 函数定义了不同的值。trace(hello()) 语句无法确定使用哪个命名空间,因此返回此错误。

private namespace rss;
private namespace xml;

public function ErrorExamples() {
   use namespace rss;
     use namespace xml;
 trace(hello());
}

rss function hello():String {
       return "hola";
    }

    xml function hello():String {
        return "foo";
    }

通过使用具体的引用来纠正不明确的引用。以下示例 使用 namespace::function 格式来指定要使用的命名空间:

public function ErrorExamples() {

    trace(rss::hello());
    trace(xml::hello());
}
  1003 Access specifiers are not allowed with namespace attributes. You can not use both an access specifier (such as private or public) and a namespace attribute on a definition.
  1004 Namespace was not found or is not a compile-time constant. 该命名空间未知,或是运行时可能具有不同值的表达式。 检查命名空间的拼写及其定义的导入是否正确。
  1006 A super expression can be used only inside class instance methods.  
  1007 A super statement can be used only inside class instance constructors. 不能在静态成员的内部使用 super 语句。只能在类实例的内部使用 super 语句。
  1008 Attribute is invalid.  
  1010 The override attribute may be used only on class property definitions. 不能在函数块内部使用 override 关键字。
  1011 The virtual attribute may be used only on class property definitions. 声明的属性不属于某个类时(例如在函数块内部声明某个变量时),不能使用 virtual 属性。
  1012 The static attribute may be used only on definitions inside a class.  
  1013 The private attribute may be used only on class property definitions.  
  1014 The intrinsic attribute is no longer supported. ActionScript 3.0 does not support the intrinsic keyword.
  1016 Base class is final. 无法扩展超类,因为它被标记为 final
  1017 The definition of base class %s was not found.  
  1018 Duplicate class definition: %s.  
  1020 Method marked override must override another method.  
  1021 Duplicate function definition. You cannot declare more than one function with the same identifier name within the same scope.
  1022 Cannot override a final accessor.  
  1023 Incompatible override. A function marked override must exactly match the parameter and return type declaration of the function it is overriding. It must have the same number of parameters, each of the same type, and declare the same return type. If any of the parameters are optional, that must match as well. Both functions must use the same access specifier (public, private, and so on) or namespace attribute as well.
  1024 Overriding a function that is not marked for override. 如果某个类中的方法覆盖了基类中的方法,则必须使用 override 属性对其进行显式声明,如以下示例所示:

public override function foo():void{};
  1025 Cannot redefine a final method. 不能扩展该方法,因为它在基类中被标记为 final
  1026 Constructor functions must be instance methods.  
  1027 Functions cannot be both static and override.  
  1028 Functions cannot be both static and virtual.  
  1029 Functions cannot be both final and virtual.  
  1030 Must specify name of variable arguments array. …(rest) 参数定义指定:…(rest) 之后提供的所有值都收集到任一数组中。必须指定该数组的名称,如 function foo(x,...(rest)) 表达式中所示。
  1033 Virtual variables are not supported.  
  1034 Variables cannot be native.  
  1035 Variables cannot be both final and virtual.  
  1037 Packages cannot be nested.  
  1038 Target of break statement was not found.  
  1039 Target of continue statement was not found.  
  1040 Duplicate label definition.  
  1041 Attributes are not callable.  
  1042 The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code. 不能在静态成员的内部使用 this 关键字,因为 this 可能没有上下文。
  1043 Undefined namespace.  
  1044 Interface method %s in namespace %s not implemented by class %s.  
  1045 Interface %s was not found.  
  1046 Type was not found or was not a compile-time constant: %s. 用作类型声明的类或是未知,或是在运行时可能有不同值的表达式。检查导入的类是否正确以及该类的包位置是否尚未更改。此外,检查包含代码的包(不是导入的类)的定义是否正确(例如,确保使用的是正确的 ActionScript 3.0 包语法,而不是 ActionScript 2.0 包语法)。

如果要引用的类在所用的命名空间中没有定义,或者未定义为公共类,也会引发该错误:

public class Foo{}

如果您使用的是 Flex™ Builder™ 2 并且该类存在于库中,请确保为项目设置类路径。

  1047 Parameter initializer unknown or is not a compile-time constant. 用作该参数默认值的值未定义或在运行时可能具有不同的值。检查初始值设定项的拼写是否正确, 并确定初始值设定项的值不是一个会在运行时导致产生不同可能值的表达式。
  1048 Method cannot be used as a constructor. 不能创建类方法的实例。在 new 表达式中只能使用全局函数。

class D { function xx() { return 22; } }
var d:D = new D();
var x = new d.xx(); // error, method cannot be used as constructor
function yy() { this.a = 22; }
var z = new yy(); // no error, global functions can be used as constructors.
  1049 Illegal assignment to a variable specified as constant.  
  1050 Cannot assign to a non-reference value.  
  1051 Return value must be undefined. 您正尝试在已将返回类型声明为 void 的方法中使用 return 语句。
  1052 Constant initializer unknown or is not a compile-time constant. 用来初始化该常数的值是 undefined,或在运行时可能具有不同的值。检查初始值设定项的拼写是否正确, 并确定初始值设定项的值不是一个会在运行时导致产生不同可能值的表达式。
  1053 Accessor types must match.  
  1054 Return type of a setter definition must be unspecified or void. 无法指定 setter 函数的返回值。例如,以下内容是无效的:

public function set gamma(g:Number):Number;

以下内容有效的:

public function set gamma(g:Number):void;
  1058 Property is write-only.  
  1059 Property is read-only. 此属性通过 getter 函数定义,因此,可以检索该属性的值。但是,不存在为此属性定义的 setter 函数,因此,该属性是只读的。

在以下示例中,第 3 行会生成错误,因为不存在为 xx 定义的 setter 函数:

class D { function get xx() { return 22; } }
var d:D = new D();
d.xx = 44; // error, property is read-only
  1061 Call to a possibly undefined method %s through a reference with static type %s. 要调用的方法未定义。
  1063 Unable to open file: %s.  
  1064 Invalid metadata. 无法识别此元数据。
  1065 Metadata attributes cannot have more than one element.  
  1067 Implicit coercion of a value of type %s to an unrelated type %s. 您正试图将某个对象转换为无法转换成的类型。如果 希望转换成的类不在要转换的对象的继承链中,就有可能发生此错误。 仅当编译器在严格模式下运行时,才会出现此错误。
  1068 Unable to open included file: %s.  
  1069 Syntax error: definition or directive expected. Check the syntax in the line.
  1071 Syntax error: expected a definition keyword (such as function) after attribute %s, not %s. 如果作者忘记在声明中使用“var”或“function”关键字,将会出现此错误。

public int z;// should be 'public var z:int;'

编译器遇到意外字符时,也会出现此错误。例如,以下对 trace() 函数的使用就是无效的,因为其中缺少括号(正确的语法是 trace("hello")):

trace "hello"
  1072 Syntax error: expecting xml before namespace. 正确的语句语法是 default xml namespace = ns。或者缺少关键字 xml(注意是小写形式),或者使用了错误的关键字。有关详细信息,请参阅 default xml namespace 指令。
  1073 Syntax error: expecting a catch or a finally clause.  
  1075 Syntax error: the ‘each’ keyword is not allowed without an ‘in’ operator.  
  1076 Syntax error: expecting left parenthesis before the identifier.  
  1077 Expecting CaseLabel. 在 switch 块中,编译器此时应该执行 case 语句。下面的 switch 块错误地在第一个 case 语句之前包含了对 print 的调用:

switch(x)
{
trace(2);
case 0:  trace(0); 
break
}
  1078 Label must be a simple identifier.  
  1079 A super expression must have one operand.  
  1080 Expecting increment or decrement operator.  
  1082 Expecting a single expression within parentheses.  
  1083 Syntax error: %s is unexpected. 代码行缺少某些信息。在以下示例中,最后一个加号的后面需要带有某个表达式(如其它数字):

var sum:int = 1 + 2 + ;
  1084 Syntax error: expecting %s before %s. 此处不需要该表达式。如果错误是“Expecting right brace before end of program”,则表示代码块缺少右大括号 (})。

如果错误是“Expecting left parenthesis before _”,则表示条件表达式中可能遗漏了括号,如下面的示例(有意出错)所示:

var fact:int = 1 * 2 * 3;
if fact > 2 {
  var bigger:Boolean = true;
}
  1086 Syntax error: expecting semicolon before %s.  
  1087 Syntax error: extra characters found after end of program.  
  1093 Syntax error.  
  1094 Syntax error: A string literal must be terminated before the line break.  
  1095 Syntax error: A string literal must be terminated before the line break.  
  1097 Syntax error: input ended before reaching the closing quotation mark for a string literal.  
  1099 Syntax error.  
  1100 Syntax error: XML does not have matching begin and end tags.  
  1102 Cannot delete super descendants.  
  1103 Duplicate namespace definition. 已多次定义该命名空间。请删除或修改重复的定义。
  1105 Target of assignment must be a reference value. 可以给变量赋值,但是不能将一个值赋给另外一个值。
  1106 Operand of increment must be a reference. 操作数必须是变量、数组中的元素或对象的属性。
  1107 Increment operand is invalid. 操作数必须是变量、数组中的元素或对象的属性。
  1108 Decrement operand is invalid. 操作数必须是变量、数组中的元素或对象的属性。
  1109 Expecting an expression. 代码中的某一部分缺少表达式。例如,以下代码会生成此错误(if 语句中缺少某项条件):

var x = (5 > 2) ? 
trace(x)
  1110 Missing XML tag name.  
  1112 Possible infinite recursion due to this file include: %s. 所要编译的源代码中包含的某个文件中包含可能导致 无限循环的其它 include 语句。例如,下面的 a.as 和 b.as 文件会生成此错误,因为每个文件都试图包含另外一个文件。

文件 a.as 包含以下代码,它试图包含文件 b.as:

import foo.bar.baz;
include "b.as"
trace(2);

文件 b.as 包含以下代码,它试图包含文件 a.as:

include "a.as"
  1113 Circular type reference was detected in %s. 某个类正在尝试扩展超类。例如,如果类 B 是从类 A 继承而来,则 A 不能扩展 B:

class a extends b { }
class b extends a { }
  1114 The public attribute can only be used inside a package.  
  1115 The internal attribute can only be used inside a package.  
  1116 A user-defined namespace attribute can only be used at the top level of a class definition.  
  1118 Implicit coercion of a value with static type %s to a possibly unrelated type %s. 所使用的值不是预期的类型,并且不存在将其转换为预期类型的隐式强制。

可能使用的是超类型,但需要的是子类型。例如:

class A {}
var a:A = new A(); 
class B extends A { function f() }
var b : B = a // error

最后一个语句会引发一个错误,因为该语句尝试将 A 类型的对象赋给 B 类型的变量。

同样,以下语句定义的 foo() 函数采用 B 类型的参数。语句 foo(a); 会出错,因为该语句试图使用 A 类型的参数:

function foo(x:B) { }
foo(a);

此外,下面的语句也会出错, 因为 foo2() 的返回值类型必须是 B:

function foo2():B { return new A(); }
  1119 Access of possibly undefined property %s through a reference with static type %s. 您正在尝试访问指定的对象所没有的属性。例如,以下代码会生成此错误,因为 int 对象没有名为 assortment 的属性:

var i:int = 44;
var str:String = i.assortment;

仅当编译器在严格模式下运行时,才会出现此错误。

  1120 Access of undefined property %s. 正在试图访问未定义的变量。例如,如果尚未定义变量 huh,则调用该变量时就会生成此错误:

huh = 55;

仅当编译器在严格模式下运行时,才会出现此错误。

  1121 A getter definition must have no parameters.  
  1122 A setter definition must have exactly one parameter.  
  1123 A setter definition cannot have optional parameters.  
  1124 Return type of a getter definition must not be void. getter 函数模拟变量。由于变量类型不能为 void,因此不能将 getter 函数的返回类型声明为 void。
  1125 Methods defined in an interface must not have a body.  
  1126 Function does not have a body.  
  1127 Attribute %s was specified multiple times. 在同一语句中多次指定某个属性。例如,语句 public static public var x; 就会生成此错误,因为该语句两次指定变量 x 是公共变量。请删除重复的声明。
  1129 Duplicate interface definition: %s. 请更改或删除重复的定义。
  1130 A constructor cannot specify a return type.  
  1131 Classes must not be nested.  
  1132 The attribute final can only be used on a method defined in a class.  
  1133 The native attribute can only be used with function definitions.  
  1134 The dynamic attribute can only be used with class definitions.  
  1135 Syntax error: %s as not a valid type.  
  1136 Incorrect number of arguments. Expected %s. 函数需要的参数数量与提供的参数数量不同。例如, 下面定义的函数 goo 具有两个参数:

class A { static function goo(x:int,y:int) 
{ return(x+y); } }

下面的语句可能会引发错误,因为该语句提供了三个参数:

A.goo(1,2,3);
  1137 Incorrect number of arguments. Expected no more than %s.  
  1138 Required parameters are not permitted after optional parameters.  
  1139 Variable declarations are not permitted in interfaces.  
  1140 Parameters specified after the …rest parameter definition keyword can only be an Array data type.  
  1141 A class can only extend another class, not an interface.  
  1142 An interface can only extend other interfaces, but %s is a class. 正在试图使用接口扩展类。一个接口只能扩展另外一个 接口。
  1143 The override attribute can only be used on a method defined in a class.  
  1144 Interface method %s in namespace %s is implemented with an incompatible signature in class %s. 方法签名必须完全匹配。
  1145 Native methods cannot have a body. 不能使用 native,因为它是一个保留关键字。
  1146 A constructor cannot be a getter or setter method.  
  1147 An AS source file was not specified.  
  1149 The return statement cannot be used in static initialization code.  
  1150 The protected attribute can only be used on class property definitions.  
  1151 A conflict exists with definition %s in namespace %s. 在同一个作用域内,不能使用相同的标识符名称声明多个变量,除非将所有这些变量都声明为相同的类型。在 ActionScript 3.0 中, 不同的代码块(例如在同一个函数定义中的两个 for 循环中使用的块) 被视为属于同一个作用域。

以下代码示例可以正确地将变量 x 转换为相同类型:

function test()
{
   var x:int = 3;
 for(var x:int = 33; x < 55; x++)
    trace(x);
  for(var x:int = 11; x < 33; x++)
    trace(x)
}

以下代码示例会生成错误,因为变量声明和 for 循环中的类型转换是不同的:

function test()
{
 var x:String = "The answer is";
    for(var x:int = 33; x < 55; x++) // error
   trace(x);
  for(var x:unit = 11; x < 33; x++) // error
  trace(x)
}
  1152 A conflict exists with inherited definition %s in namespace %s.  
  1153 A constructor can only be declared public.  
  1154 Only one of public, private, protected, or internal can be specified on a definition.  
  1155 Accessors cannot be nested inside other functions.  
  1156 Interfaces cannot be instantiated with the new operator.  
  1157 Interface members cannot be declared public, private, protected, or internal.  
  1158 Syntax error: missing left brace ({) before the function body.  
  1159 The return statement cannot be used in package initialization code.  
  1160 The native attribute cannot be used in interface definitions. 不能使用 native,因为它是一个保留关键字。
  1162 Only one namespace attribute can be used per definition.  
  1163 Method %s conflicts with definition inherited from interface %s.  
  1165 Interface attribute %s is invalid.  
  1166 Namespace declarations are not permitted in interfaces.  
  1167 Class %s implements interface %s multiple times. 该类多次实现同一个接口。例如,以下代码就会生成此错误,因为类 C 有两次实现接口 A:

interface A {  public function f();  };
class C implements A,A {
public function f() { trace("f"); }
}

正确的实现语句应为 class C implements A {

  1168 Illegal assignment to function %s. 正在试图重新定义函数。例如,以下代码定义的函数 topLevel() 要输出“top”一词。第二个语句会生成错误,因为该语句赋给该函数不同的返回值:

function topLevel() { trace("top"); }
topLevel = function() { trace("replacement works in ~");} // error
  1169 Namespace attributes are not permitted on interface methods.  
  1170 Function does not return a value. 如果返回类型不是 void, 那么函数中每个可能的控制流都必须返回值。下面的函数 f(x) 不会生成错误,因为 if..else 语句总是返回值:

function f(x):int
{
if (x)
        return 2;
else
     return 3;
} // no error

但是,下面的函数 g(x) 会生成该错误,因为 switch 语句并非总是返回值。

function g(x:int):int
{
switch(x)
{
         case 1: return 1;
          case 2: return 2:
}
// return 2;//uncomment to remove the error
}

只有函数声明的返回类型不是 void 时,才启用此检查。

  1171 A namespace initializer must be either a literal string or another namespace.  
  1172 Definition %s could not be found.  
  1173 Label definition is invalid.  
  1176 Comparison between a value with static type %s and a possibly unrelated type %s. This error is enabled in strict mode.
  1177 The return statement cannot be used in global initialization code.  
  1178 Attempted access of inaccessible property %s through a reference with static type %s.  
  1180 Call to a possibly undefined method %s. This error appears only when the compiler is running in strict mode.
  1181 Forward reference to base class %s.  
  1182 Package cannot be used as a value: %s.  
  1184 Incompatible default value of type %s where %s is expected.  
  1185 The switch has more than one default, but only one default is allowed.  
  1188 Illegal assignment to class %s.  
  1189 Attempt to delete the fixed property %s. Only dynamically defined properties can be deleted. Delete removes dynamically defined properties from an object. Declared properties of a class can not be deleted. This error appears only when the compiler is running in strict mode.
  1190 Base class was not found or is not a compile-time constant.  
  1191 Interface was not found or is not a compile-time constant.  
  1192 The static attribute is not allowed on namespace definitions.  
  1193 Interface definitions must not be nested within class or other interface definitions.  
  1194 The prototype attribute is invalid.  
  1195 Attempted access of inaccessible method %s through a reference with static type %s. 要么从其它类调用 private 方法,要么调用未使用的命名空间中定义的方法。如果调用的是未使用的命名空间中定义的方法,请为必需的命名空间添加 use 语句。
  1196 Syntax error: expecting an expression after the throw.  
  1197 The class %s cannot extend %s since both are associated with library symbols or the main timeline.  
  1198 Attributes are not allowed on package definition.  
  1199 Internal error: %s.  
  1200 Syntax error: invalid for-in initializer, only 1 expression expected.  
  1201 A super statement cannot occur after a this, super, return, or throw statement.  
  1202 Access of undefined property %s in package %s. 正在试图访问包中未定义的变量。例如,如果尚未定义变量 p.huh,调用该变量时就会生成此错误:

p.huh = 55;

只有当编译器在严格模式下运行时才会显示此错误。

  1203 No default constructor found in base class %s. You must explicitly call the constructor of the base class with a super() statement if it has 1 or more required arguments.
  1204 /* found without matching */ . 找到了指示注释开始位置的字符“/*”,但未找到指示注释块结束位置的对应字符“*/”。
  1205 Syntax Error: expecting a left brace({)or string literal("").  
  1206 A super statement can be used only as the last item in a constructor initializer list. 不能在构造函数内部使用 super 语句。只能将 super 语句用作构造函数初始值设定项列表中的最后一项。
  1207 The this keyword can not be used in property initializers. 不能在属性初始值设定项内部使用 this 关键字。
  1208 The initializer for a configuration value must be a compile time constant. 编译时,配置值的初始值设定项必须是已知值。初始值设定项必须是常数字符串、数值、布尔值或 是对其它先前定义的配置值的引用。
  1209 A configuration variable may only be declared const. 定义配置变量时,必须将其声明为 const。
  1210 A configuration value must be declared at the top level of a program or package. 必须在程序或包的顶级声明配置值。
  1211 Namespace %s conflicts with a configuration namespace. 命名空间可能与配置命名空间使用不同的名称。
  1212 Precision must be an integer between 1 and 34.  
  1213 Syntax error: numeric use statement must be first in block.  

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图