Question

I notice that when Flash warns me of run-time errors over multiple layers of script the line of error doesn't seem accurate (I'm pretty sure it just tells me what line of all the code the error is on, not the specific line of the layer I'm working with). The warning doesn't even tell me what layer the problem is on. For example:

TypeError: Error #1009: Cannot access a property or method of a null object reference. at _example_fla::MainTimeline/my_function()[_example_fla.MainTimeline::frame1:523]

Is there anyway I can get Flash to tell me what layer, frame and line (on that layer) the issue occurs?

Was it helpful?

Solution

No, unfortunately, Flash doesn't give this information about layers. You have to do a little math.

The error is occurring on Frame 1 (you can see that after the :: on the message.)

To find the layer, you have to count the lines of code on each layer, from the top down. Flash sees it all as one long block of code. Thus, FOR EXAMPLE, if layer 1 has 452 lines, layer 2 has 12, and layer 3 has 59, you can do the math and find your error on line 57 of that third layer.

523-452=71

71-12=59

Thus, line 57, layer 3

This can get annoying. It is for this reason that the standard practice at my company for code on the timeline is to put all code (except, usually, event listeners)on a layer by itself, at the top of the stack, called SCRIPTS. Nothing else lives in that layer - it is just empty with code. It makes life so much easier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top