

(If you have a document class it will need to extend the MovieClip class to do this.) And place a trace("code") just above the problematic line of code and test. You can always confirm that by using the trace() function: Place a trace("frame") in the keyframe that contains your object. But first make sure that frame plays before your object reference. If you are certain you have an on-stage object whose instance name (in the properties panel) matches your actionscript reference and it is in a frame that plays no later than your code referencing that object, you may need to take a few steps backwards to solve the problem. However, those errors can still be fixed. And if that panel is cleared or the problem was created far enough in the past that the steps causing the error are no longer present in the history panel, there's no way (known to me) to deduce what caused the error. I have seen some 1009 errors that are impossible to diagnose without checking the history panel. There are, however, more obtuse ways to trigger a 1009 error when you create and delete objects on-stage and especially if you use timeline tweening. Then you can be certain the names are the same. Instead of comparing two names and trying to confirm they are the same, (eg, an instance name in the properties panel and an actionscript name), it's more reliable to copy the name from one location and paste it to the other. Of course, typos are every coders burden and are a common cause of 1009 errors. Use the trace() function to find which object(s) is(are) null: If there's more than one object in the problematic line of code, for example: Here's the same error trying to reference a null object method: Precisely the same error will occur in many different guises. To create the object with code, use the "new" constructor: To remedy this problem, you must create the referenced object either on-stage or with actionscript.

Trying to access the x property (or any other property of mc) is going to result in a 1009 error because you cannot access a property of a null (or non-existant) object. The variable mc has been declared but is null because no movieclip exists and and it has not been created. Is the simplest code that would trigger a 1009 error. For example, if there is no object mc on-stage, If there is only one object reference in the problematic line of code, you can conclude that object does not exist when that line of code executes. Fortunately, most of these errors are quick and easy to fix (assuming you read the Permit Debugging section). This is the most common error posted on the Adobe Flash-related Forums. Some of it may be helpful.īelow are the error messages (in numeric order) most commonly cited in the ActionScript 3 forum and help for resolving.ġ009: Cannot access a property or method of a null object reference. Searching for "Flash as3 error xxxx" should bring up all sorts of information. The additional information may be enough to save hours of hair-pulling frustration.īut if that's not enough help, don't be afraid to use a search engine. This is the first place you should check when you encounter an error message that you do not completely understand.

As of this writing that link is endixes.html but that may change especially as updated help files are published by Adobe. But if you need further explanation, check the Flash help file Appendixes (Help > Flash Help > ActionScript 3.0 and Components > ActionScript 3.0 Reference for the Adobe Flash Platform > Appendixes), where you'll find Compiler Errors and Run-Time Errors which comprise a complete listing of all error messages often with additional and sometimes helpful information. You may find some error messages need no explanation (like compiler error "1021 : Duplicate function definition").

But, in all scenarios (except for errors that occur during an asynchronous event like file loading), the error message will indicate the exact line number of the problematic code, if you tick "Permit debugging". Error messages' exact contents depend on the error type (compile-time or run-time), the exact error and the location (timeline or class file) of your problematic code. First, click File > Publish Settings > Flash, tick the "Permit debugging" checkbox, then click OK and retest.īy ticking "Permit debugging" you will see more detailed/helpful error messages.
