The following is a list of compilation errors that the compiler generates when it encounters invalid code. A subset of these errors is detected only when compiling code in strict mode. Strict mode adds three constraints not found in the standard language:

See also

Compiler Warnings
Run-Time Errors

 CodeMessageDescription
 1000Ambiguous reference to _. A reference might be to more than one item. For example, the following uses the namespaces rss and xml, each of which defines a different value for the hello() function. The trace(hello()) statement returns this error because it cannot determine which namespace to use.
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";
    }

Correct an ambiguous reference by making the reference specific. The following example uses the form namespace::function to specify which namespace to use:

public function ErrorExamples() {
    
    trace(rss::hello());
    trace(xml::hello());
}
 1003Access 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.
 1004Namespace was not found or is not a compile-time constant. The namespace is either unknown or is an expression that could have different values at run time. Check that you are spelling the namespace correctly and that its definition is imported correctly.
 1006A super expression can be used only inside class instance methods. 
 1007A super statement can be used only inside class instance constructors. You cannot use the super statement within static members. You can use the super statement only within class instances.
 1008Attribute is invalid. 
 1010The override attribute may be used only on class property definitions. You cannot use the override keyword within a function block.
 1011The virtual attribute may be used only on class property definitions. You cannot use the virtual attribute when you declare a property that does not belong to a class (for example, when you declare a variable within a function block).
 1012The static attribute may be used only on definitions inside a class. 
 1013The private attribute may be used only on class property definitions. 
 1014The intrinsic attribute is no longer supported. ActionScript 3.0 does not support the intrinsic keyword.
 1016Base class is final. The superclass cannot be extended because it is marked as final.
 1017The definition of base class _ was not found. 
 1018Duplicate class definition: _. 
 1020Method marked override must override another method. 
 1021Duplicate function definition. You cannot declare more than one function with the same identifier name within the same scope.
 1022Cannot override a final accessor. 
 1023Incompatible 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.
 1024Overriding a function that is not marked for override. If a method in a class overrides a method in a base class, you must explicitly declare it by using the override attribute, as this example shows:
public override function foo():void{};
 1025Cannot redefine a final method. The method cannot be extended because it is marked as final in the base class.
 1026Constructor functions must be instance methods. 
 1027Functions cannot be both static and override. 
 1028Functions cannot be both static and virtual. 
 1029Functions cannot be both final and virtual. 
 1030Must specify name of variable arguments array. The ...(rest) parameter definition specifies that all values supplied after ...(rest) are collected into any array. You must specify a name for the array, as in the expression function foo(x,...(rest)).
 1033Virtual variables are not supported. 
 1034Variables cannot be native. 
 1035Variables cannot be both final and virtual. 
 1037Packages cannot be nested. 
 1038Target of break statement was not found. 
 1039Target of continue statement was not found. 
 1040Duplicate label definition. 
 1041Attributes are not callable. 
 1042The this keyword can not be used in static methods. It can only be used in instance methods, function closures, and global code. You cannot use the this keyword within a static member, because this would have no context.
 1043Undefined namespace. 
 1044Interface method _ in namespace _ not implemented by class _. 
 1045Interface _ was not found. 
 1046Type was not found or was not a compile-time constant: _. The class used as a type declaration is either unknown or is an expression that could have different values at run time. Check that you are importing the correct class and that its package location has not changed. Also, check that the package that contains the code (not the imported class) is defined correctly (for example, make sure to use proper ActionScript 3.0 package syntax, and not ActionScript 2.0 syntax).

The error can also occur if the class being referenced is not defined in a namespace that is in use or is not defined as public:

public class Foo{}

If you are using Flex™ Builder™ 2 and the class is in a library, make sure to set the class path for the project.

 1047Parameter initializer unknown or is not a compile-time constant. The value used as the default value for the parameter is either undefined or could have different values at run time. Check that the initializer is spelled correctly, and that the initializer value isn't an expression that could result in different possible values at run time.
 1048Method cannot be used as a constructor. It is not possible to create an instance of a method of a class. Only global functions can be used in new expressions.
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.
 1049Illegal assignment to a variable specified as constant. 
 1050Cannot assign to a non-reference value. 
 1051Return value must be undefined. You are attempting to use the return statement within a method that has a declared return type void.
 1052Constant initializer unknown or is not a compile-time constant. The value used to initialize the constant is either undefined or could have different values at run time. Check that the initializer is spelled correctly, and that the initializer value isn't an expression that could result in different possible values at run time.
 1053Accessor types must match. 
 1054Return type of a setter definition must be unspecified or void. You cannot specify a return value for a setter function. For example, the following is invalid:
public function set gamma(g:Number):Number;

The following is valid:

public function set gamma(g:Number):void;
 1058Property is write-only. 
 1059Property is read-only. This property is defined through a getter function, which allows you to retrieve that property's value. There is no setter function defined for this property, however, so it is read-only.

In the following example, line 3 generates an error because there is no setter function defined for xx:

class D { function get xx() { return 22; } }
var d:D = new D();
d.xx = 44; // error, property is read-only
 1061Call to a possibly undefined method _ through a reference with static type _. You are calling a method that is not defined.
 1063Unable to open file: _. 
 1064Invalid metadata. This metadata is unrecognized.
 1065Metadata attributes cannot have more than one element. 
 1067Implicit coercion of a value of type _ to an unrelated type _. You are attempting to cast an object to a type to which it cannot be converted. This can happen if the class you are casting to is not in the inheritance chain of the object being cast. This error appears only when the compiler is running in strict mode.
 1068Unable to open included file: _. 
 1069Syntax error: definition or directive expected. Check the syntax in the line.
 1071Syntax error: expected a definition keyword (such as function) after attribute _, not _. This error will occur if the author forgets to use the "var" or "function" keyword in a declaration.
public int z;// should be 'public var z:int;'
This error might also occur when the compiler encounters an unexpected character. For example, the following use of the trace() function is invalid, because of the missing parentheses (the correct syntax is trace("hello")):
trace "hello"
 1072Syntax error: expecting xml before namespace. The correct statement syntax is default xml namespace = ns. Either the keyword xml (note the lowercase) is missing or an incorrect keyword was used. For more information, see the default xml namespace directive.
 1073Syntax error: expecting a catch or a finally clause. 
 1075Syntax error: the 'each' keyword is not allowed without an 'in' operator. 
 1076Syntax error: expecting left parenthesis before the identifier. 
 1077Expecting CaseLabel. The compiler expected a case statement at this point in the switch block. The following switch block incorrectly includes a call to print before the first case statement:
switch(x)
{
trace(2);
case 0:  trace(0); 
break
}
 1078Label must be a simple identifier. 
 1079A super expression must have one operand. 
 1080Expecting increment or decrement operator. 
 1082Expecting a single expression within parentheses. 
 1083Syntax error: _ is unexpected. The line of code is missing some information. In the following example, some expression (such as another number) needs to be included after the final plus sign:
var sum:int = 1 + 2 + ;
 1084Syntax error: expecting _ before _. The expression was unexpected at this point. If the error says "Expecting right brace before end of program," a block of code is missing a closing brace (}).

If the error says "Expecting left parenthesis before _," you may have omitted a parenthesis from a conditional expression, as shown in the following example, which is intentionally incorrect:

var fact:int = 1 * 2 * 3;
if fact > 2 {
	var bigger:Boolean = true;
}
 1086Syntax error: expecting semicolon before _. 
 1087Syntax error: extra characters found after end of program. 
 1093Syntax error. 
 1094Syntax error: A string literal must be terminated before the line break. 
 1095Syntax error: A string literal must be terminated before the line break. 
 1097Syntax error: input ended before reaching the closing quotation mark for a string literal. 
 1099Syntax error. 
 1100Syntax error: XML does not have matching begin and end tags. 
 1102Cannot delete super descendants. 
 1103Duplicate namespace definition. You defined the namespace more than once. Delete or modify the duplicate definition.
 1105Target of assignment must be a reference value. You can assign a value to a variable, but you cannot assign a value to another value.
 1106Operand of increment must be a reference. The operand must be a variable, an element in an array, or a property of an object.
 1107Increment operand is invalid. The operand must be a variable, an element in an array, or a property of an object.
 1108Decrement operand is invalid. The operand must be a variable, an element in an array, or a property of an object.
 1109Expecting an expression. An expression is missing in a part of the code. For example, the following produces this error (there is a condition missing from the if statement:
var x = (5 > 2) ? 
trace(x)
 1110Missing XML tag name. 
 1112Possible infinite recursion due to this file include: _. A file that is included in the source being compiled contains other include statements that would cause an infinite loop. For example, the following files. a.as and b.as, generate this error because each file tries to include the other.

File a.as contains the following, which attempts to include the file b.as:

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

File b.as contains the following, which attempts to include the file a.as:

include "a.as"
 1113Circular type reference was detected in _. A class is trying to extend a superclass. For example, class A cannot extend class B if B inherits from A:
class a extends b { }
class b extends a { }
 1114The public attribute can only be used inside a package. 
 1115The internal attribute can only be used inside a package. 
 1116A user-defined namespace attribute can only be used at the top level of a class definition. 
 1118Implicit coercion of a value with static type _ to a possibly unrelated type _. You are using a value that is not of the expected type and no implicit coercion exists to convert it to the expected type.

Perhaps you are using a supertype where a subtype is expected. For example:

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

The last statement generates an error because it attempts to assign an object of type A to a variable of type B.

Similarly, the following defines the foo() function, which takes a parameter of type B. The statement foo(a); generates an error because it attempts to use a parameter of type A:

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

Also, the following statement generates an error because the returned value for foo2() must be type B:

function foo2():B { return new A(); }
 1119Access of possibly undefined property _ through a reference with static type _. You are attempting to access a property that does not exist for the specified object. For example, the following code generates this error because an int object does not have a property named assortment:
var i:int = 44;
var str:String = i.assortment;
This error appears only when the compiler is running in strict mode.
 1120Access of undefined property _. You are attempting to access an undefined variable. For example, if the variable huh has not been defined, a call to it generates this error:
huh = 55;
This error can appear only when the compiler is running in strict mode.
 1121A getter definition must have no parameters. 
 1122A setter definition must have exactly one parameter. 
 1123A setter definition cannot have optional parameters. 
 1124Return type of a getter definition must not be void. A getter function simulates a variable. Because variables cannot be of type void, you cannot declare getter functions to return type void.
 1125Methods defined in an interface must not have a body. 
 1126Function does not have a body. 
 1127Attribute _ was specified multiple times. You specified an attribute more than once in the same statement. For example, the statement public static public var x; generates this error because it specifies that the variable x is public twice. Delete duplicate declarations.
 1129Duplicate interface definition: _. Change or delete the duplicate definitions.
 1130A constructor cannot specify a return type. 
 1131Classes must not be nested. 
 1132The attribute final can only be used on a method defined in a class. 
 1133The native attribute can only be used with function definitions. 
 1134The dynamic attribute can only be used with class definitions. 
 1135Syntax error: _ is not a valid type. 
 1136Incorrect number of arguments. Expected _. The function expects a different number of arguments than those you provided. For example, the following defines function goo, which has two arguments:
class A { static function goo(x:int,y:int) 
{ return(x+y); } }

The following statement would generate an error because it provides three arguments:

A.goo(1,2,3);
 1137Incorrect number of arguments. Expected no more than _. 
 1138Required parameters are not permitted after optional parameters. 
 1139Variable declarations are not permitted in interfaces. 
 1140Parameters specified after the ...rest parameter definition keyword can only be an Array data type. 
 1141A class can only extend another class, not an interface. 
 1142An interface can only extend other interfaces, but _ is a class. You are attempting to have the interface extend a class. An interface can only extend another interface.
 1143The override attribute can only be used on a method defined in a class. 
 1144Interface method _ in namespace _ is implemented with an incompatible signature in class _. Method signatures must match exactly.
 1145Native methods cannot have a body. You cannot use native because it is a reserved keyword.
 1146A constructor cannot be a getter or setter method. 
 1147An AS source file was not specified. 
 1149The return statement cannot be used in static initialization code. 
 1150The protected attribute can only be used on class property definitions. 
 1151A conflict exists with definition _ in namespace _. You cannot declare more than one variable with the same identifier name within the same scope unless all such variables are declared to be of the same type. In ActionScript 3.0, different code blocks (such as those used in two for loops in the same function definition) are considered to be in the same scope.

The following code example correctly casts the variable x as the same type:

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)
}

The following code example generates an error because the type casting in the variable declaration and the for loops are different:

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 _ in namespace _. 
 1153A constructor can only be declared public. 
 1154Only one of public, private, protected, or internal can be specified on a definition. 
 1155Accessors cannot be nested inside other functions. 
 1156Interfaces cannot be instantiated with the new operator. 
 1157Interface members cannot be declared public, private, protected, or internal. 
 1158Syntax error: missing left brace ({) before the function body. 
 1159The return statement cannot be used in package initialization code. 
 1160The native attribute cannot be used in interface definitions. You cannot use native because it is a reserved keyword.
 1162Only one namespace attribute can be used per definition. 
 1163Method _ conflicts with definition inherited from interface _. 
 1165Interface attribute _ is invalid. 
 1166Namespace declarations are not permitted in interfaces. 
 1167Class _ implements interface _ multiple times. The class implements the same interface more than once. For example, the following generates this error because class C implements interface A twice:
interface A {  public function f();  };
class C implements A,A {
public function f() { trace("f"); }
}

The correct implementing statement should be class C implements A {.

 1168Illegal assignment to function _. You are attempting to redefine a function. For example, the following defines the function topLevel() to print the word "top". The second statement generates an error because it assigns a different return value to the function:
function topLevel() { trace("top"); }
topLevel = function() { trace("replacement works in ~");} // error
 1169Namespace attributes are not permitted on interface methods. 
 1170Function does not return a value. Every possible control flow in a function must return a value whenever the return type is something other than void. The following function f(x) does not generate an error because the if..else statement always returns a value:
function f(x):int
{
if (x)
    	return 2;
else
    	return 3;
} // no error

However, the function g(x) below generates the error because the switch statement does not always return a value.

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

This checking is enabled only when the function declares a return type other than void.

 1171A namespace initializer must be either a literal string or another namespace. 
 1172Definition _ could not be found. 
 1173Label definition is invalid. 
 1176Comparison between a value with static type _ and a possibly unrelated type _. This error is enabled in strict mode.
 1177The return statement cannot be used in global initialization code. 
 1178Attempted access of inaccessible property _ through a reference with static type _. 
 1180Call to a possibly undefined method _. This error appears only when the compiler is running in strict mode.
 1181Forward reference to base class _. 
 1182Package cannot be used as a value: _. 
 1184Incompatible default value of type _ where _ is expected. 
 1185The switch has more than one default, but only one default is allowed. 
 1188Illegal assignment to class _. 
 1189Attempt to delete the fixed property _. 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.
 1190Base class was not found or is not a compile-time constant. 
 1191Interface was not found or is not a compile-time constant. 
 1192The static attribute is not allowed on namespace definitions. 
 1193Interface definitions must not be nested within class or other interface definitions. 
 1194The prototype attribute is invalid. 
 1195Attempted access of inaccessible method _ through a reference with static type _. You are either calling a private method from another class, or calling a method defined in a namespace that is not in use. If you are calling a method defined in an unused namespace, add a use statement for the required namespace.
 1196Syntax error: expecting an expression after the throw. 
 1197The class _ cannot extend _ since both are associated with library symbols or the main timeline. 
 1198Attributes are not allowed on package definition. 
 1199Internal error: _. 
 1200Syntax error: invalid for-in initializer, only 1 expression expected. 
 1201A super statement cannot occur after a this, super, return, or throw statement. 
 1202Access of undefined property _ in package _. You are attempting to access an undefined variable in a package. For example, if the variable p.huh has not been defined, a call to it generates this error:
p.huh = 55;
This error can only appear when the compiler is running in strict mode.
 1203No default constructor found in base class _. 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 */ . The characters '/*' where found, which indicate the beginning of a comment, but the corresponding characters, '*/', which indicate the end of the comment block, were not found.
 1205Syntax Error: expecting a left brace({)or string literal(""). 
 1206A super statement can be used only as the last item in a constructor initializer list. You cannot use the super statement within a constructor. You can use the super statement only as the last item in the constructor initializer list.
 1207The this keyword can not be used in property initializers. You cannot use the this keyword within a property initializer.
 1208The initializer for a configuration value must be a compile time constant. The initializer of a configuration value must be a value known at compile time. The initializer may be a constant string, number, or boolean, or a reference to another previously defined configuration value.
 1209A configuration variable may only be declared const. When defining a configuration variable, it must be declared as const.
 1210A configuration value must be declared at the top level of a program or package. A configuration value must be declared at the top level of a program or package.
 1211Namespace _ conflicts with a configuration namespace. A namespace may not have the same name as a configuration namespace.
 1212Precision must be an integer between 1 and 34. 
 1214Incompatible Version: can not reference definition _ introduced in version _ from code with version _. 
 1215Invalid initialization: conversion to type _ loses data.