Error Handling
As you build applications with Flash MX 2004 and Flash MX 2004 Professional, you will need to spend time managing bugs and errors in your ActionScript.
Enhancements to Trace
With older versions of ActionScript, the most common way to manage bug tracking was to add a trace to your code. For instance, you could add the following to post to the Output window the results of the trace:
Trace(variableName);
A big improvement with Flash 2004 is that the Output panel can now be docked along with other panels.
Error Messages
Flash MX 2004 Professional can now post error messages to the Output panel. These messages all come as cryptic four-numbered code. The code can be cross-referenced so that you can gain a full understanding of what the code means. Or you can use the following cheat sheet:
Error Number |
Message Text |
1093 |
A class name was expected. |
1094 |
A base class name is expected after the extends keyword. |
1095 |
A member attribute was used incorrectly. |
1096 |
The same member name may not be repeated more than once. |
1097 |
All member functions need to have names. |
1099 |
This statement is not permitted in a class definition. |
1100 |
A class or interface has already been defined with this name. |
1101 |
Type mismatch. |
1102 |
There is no class with the name <ClassName>. |
1103 |
There is no property with the name <propertyName>. |
1104 |
A function call on a non-function was attempted. |
1105 |
Type mismatch in assignment statement: found [lhs-type] where [rhs-type] is required. |
1106 |
The member is private and cannot be accessed. |
1107 |
Variable declarations are not permitted in interfaces. |
1108 |
Event declarations are not permitted in interfaces. |
1109 |
Getter/setter declarations are not permitted in interfaces. |
1110 |
Private members are not permitted in interfaces. |
1111 |
Function bodies are not permitted in interfaces. |
1112 |
A class may not extend itself. |
1113 |
An interface may not extend itself. |
1114 |
There is no interface defined with this name. |
1115 |
A class may not extend an interface. |
1116 |
An interface may not extend a class. |
1117 |
An interface name is expected after the implements keyword. |
1118 |
A class may not implement a class, only interfaces. |
1119 |
The class must implement method methodName from interface interfaceName. |
1120 |
The implementation of an interface method must be a method, not a property. |
1121 |
A class may not extend the same interface more than once. |
1122 |
The implementation of the interface method doesn't match its definition. |
1123 |
This construct is available only in ActionScript 1.0. |
1124 |
This construct is available only in ActionScript 2.0. |
1125 |
Static members are not permitted in interfaces. |
1126 |
The expression returned must match the function's return type. |
1127 |
A return statement is required in this function. |
1128 |
Attribute used outside class. |
1129 |
A function with return type void may not return a value. |
1130 |
The extends clause must appear before the implements clause. |
1131 |
A type identifier is expected after the :. |
1132 |
Interfaces must use the extends keyword, not implements. |
1133 |
A class cannot extend more than one class. |
1134 |
An interface cannot extend more than one interface. |
1135 |
There is no method with the name <methodName>. |
1136 |
This statement is not permitted in an interface definition. |
1137 |
A set function requires exactly one parameter. |
1138 |
A get function requires no parameters. |
1139 |
Classes may be defined only in external ActionScript 2.0 class scripts. |
1140 |
ActionScript 2.0 class scripts may define only class or interface constructs. |
1141 |
The name of this class, <A.B.C>, conflicts with the name of another class that was loaded, <A.B>. |
1142 |
The class <ClassName> could not be loaded. |
1143 |
Interfaces may be defined only in external ActionScript 2.0 class scripts. |
1144 |
Instance variables cannot be accessed in static functions. |
1145 |
Class and interface definitions cannot be nested. |
1146 |
The property being referenced does not have the static attribute. |
1147 |
This call to super does not match the superconstructor. |
1148 |
Only the public attribute is allowed for interface methods. |
1149 |
The import keyword cannot be used as a directive. |
1150 |
You must export your movie as Flash 7 to use this action. |
1151 |
You must export your movie as Flash 7 to use this expression. |
1152 |
This exception clause is placed improperly. |
1153 |
A class must have only one constructor. |
1154 |
A constructor may not return a value. |
1155 |
A constructor may not specify a return type. |
1156 |
A variable may not be of type void. |
1157 |
A function parameter may not be of type void. |
1158 |
Static members can be only accessed directly through classes. |
1159 |
Multiple implemented interfaces contain same method with different types. |
1160 |
There is already a class or interface defined with this name. |
1161 |
Classes, interfaces, and built-in types may not be deleted. |
1162 |
There is no class with this name. |
1163 |
The keyword <keyword> is reserved for ActionScript 2.0 and cannot be used here. |
1164 |
Custom attribute definition was not terminated. |
1165 |
Only one class or interface can be defined per ActionScript 2.0 .as file. |
1166 |
The class being compiled, <A.b>, does not match the class that was imported, <A.B>. |
1167 |
You must enter a class name. |
1168 |
The class name you entered contains a syntax error. |
1169 |
The interface name you entered contains a syntax error. |
1170 |
The base class name you entered contains a syntax error. |
1171 |
The base interface name you entered contains a syntax error. |
1172 |
You must enter an interface name. |
1173 |
You must enter a class or interface name. |
1174 |
The class or interface name you entered contains a syntax error. |
1175 |
variable is not accessible from this scope. |
1176 |
Multiple occurrences of the get/set/private/public/static attribute were found. |
1177 |
A class attribute was used incorrectly. |
1178 |
Instance variables and functions cannot be used to initialize static variables. |
1179 |
Runtime circularities were discovered between the following classes: %1 |
1180 |
The currently targeted Flash Player does not support debugging. |
1181 |
The currently targeted Flash Player does not support the releaseOutside event. |
1182 |
The currently targeted Flash Player does not support the dragOver event. |
1183 |
The currently targeted Flash Player does not support the dragOut event. |
1184 |
The currently targeted Flash Player does not support dragging actions. |
1185 |
The currently targeted Flash Player does not support the loadMovie action. |
1186 |
The currently targeted Flash Player does not support the getURL action. |
1187 |
The currently targeted Flash Player does not support the FSCommand action. |
1188 |
Import statements are not allowed inside class or interface definitions. |
1189 |
The class <A.B> cannot be imported because its leaf name is already being resolved to the class that is being defined, <C.B>. |
1190 |
The class <A.B> cannot be imported because its leaf name is already being resolved to imported class <C.B>. |
1191 |
A class' instance variables may only be initialized to compile-time constant expressions. |
1192 |
Class member functions cannot have the same name as a superclass' constructor function. |
1193 |
The name of this class, <ClassName>, conflicts with the name of another class that was loaded. |
1194 |
The superconstructor must be called first in the constructor body. |
1195 |
The identifier <className> will not resolve to built-in object <ClassName> at runtime. |
1196 |
The class <A.B.ClassName> needs to be defined in a file whose relative path is <A.B>. |
1197 |
The wildcard character * is misused in the ClassName <ClassName>. |
1198 |
The member function <classname> has a different case from the name of the class being defined, <ClassName>, and will not be treated as the class constructor at runtime. |
1199 |
The only type allowed for a for-in loop iterator is String. |
1200 |
A setter function may not return a value. |
1201 |
The only attributes allowed for constructor functions are public and private. |
Using the Debugger
There will be times when you will need to simply walk through your code. You can use the Debugger panel to help you do this.
The debugger is part of the Development panel (select Window ‡ Development Panels ‡ Debugger).
The role of the debugger is to throw information about the events of a movie. You can run the file and collect the information and review it at the end of a test, or you can select break points during the movie. If you select the line number on the left side of your code in the Actions panel, you will add a red circular marker. This is a break point. When you run the debugger, the movie will stop when you reach the break point. Adding multiple break points allows you to fine-tune where your bug or error is located. This is called "stepping through your code."
Through better error-handling by the new placement of the Output panel, the ability to use exceptions, and new support for error messages, you can now control errors in your Flash movie's code more effectively.