AS3.0常用錯誤

 Ambiguous reference to %s.  引用可能指向多項。例如,以下示例使用 rss 和 xml 命名空間,每個命名空間都爲 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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章