Resolve TypeError: Cannot access properties or methods of null object references

Source: Internet
Author: User
Tags access properties

Just using AS3 's friend.
May often encounter
' Typeerror:error #1009: Cannot access properties or methods of null object references. "

The reason for this problem is simple, the common is "object is null", "property does not exist", "method does not exist."
Take a look at the following example:
1, var List:array;
2, Trace (list.length)
As the list is instantiated, we call the attributes of his length. Ctrl+enter run. The following error has occurred

1. Typeerror:error #1009: Cannot access properties or methods of null object references.
2. At _fla::maintimeline/frame1 ()
PS: I write on the frame, so the function name is frame1, the class name is Maintimeline.

In fact, it is very good to solve the problem.
But the code hints didn't tell us which object, which attribute, which method,
Not even a single line told us.

Just tell us which function it is,
If there are only two lines of code like above ... Well, that's a good solution, though.
Achievable situation may be 10 lines ~ 20 Lines ~
Then you may have to use the exclusion of return or try ... A step-by-step solution ...


Tired ~ above is preface ... Can skip directly ...

Today we introduce a simple but not-so-common way ... Can solve the above problem ....
or the previous code
1, var List:array;
2, Trace (list.length)
But we don't use Ctrl+enter to run
We use Ctrl+shift+enter to run

After the Run Debug window appears with the following content
1, trying to start and connect to the player using the URL c:docume~1*locals~1temp unnamed -1.swf
2. The number of bytes after decompression is [SWF] c:documents and settings*local settingstemp unnamed -1.swf-1970 bytes
3. Typeerror:error #1009: Cannot access properties or methods of null object references.
4, at _fla::maintimeline/frame1 () [_fla. Maintimeline::frame1:2]
And look in the middle of the IDE.

Has told us in detail which line is the problem ...
This allows you to quickly navigate to the wrong number of rows ...
Then it's OK to deal with the problem of the line ...

PS: Debugging functions In addition to just said the function, there are many more practical functions, variable view, breakpoint debugging, we can try more, to debug debugging has a great help!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.