Main Content

You are here:

Runtime errors

A runtime error is technically any error that is picked up during the execution of a program, but for the sake of understandibility you cna think of it as really compiler errors that have just slipped through the net. Sometime they are errors that are anticipated but which the programmer can do nothing about. Most of the time though, they only emerge when certain conditions are met within your program - conditions which may never occur in 'normal' use. Of course, there may be a nerd living two doors down the road who wants to break everything in the hope of achieving something. That is one argument in favour of rigorous testing, which I won't go into now.

The range of runtime errors that can be achieved is diminishing. Alright, that's a lie, because techincally they didn't exist before ActionScript 3, but the compile-time checker is now much better at picking up the errors. They generally result from values changing outside of your control (oh why did he have to enter 03/12/2009 when all I wanted was 03/12/09 ?), which are then passed to functions. One example would be this line: gotoAndPlay("");. It passes the compiler error checker - "" is a valid string - but when it gets to the function it finds out that:ArgumentError: Error #2109: Frame label not found in scene Scene 1... .

On the upside, we still have an error number, a description and probably a line number too. You can also typeset you variables, if they're always going to be strings or whatever (var astring:String). That will force compiler errors in some circumstances. Most of the tips outlined in the compiler errors tutorial apply here also. In this case, though, you'll want the . On there is all the useful information you need about an error. If the error isn't listed there, it may be listed on the .

What to do about run-time errors? Well, by far the easiest way to track down what's giving you the grief (if you don't know already) is to comment out lines, or add in traces around them. The code required for both these options is shown on the traces and comments tutorial. If you take the 'comments' route, you can follow these steps:

If you wish to follow the 'traces' method, you can:

Either way, solving run-time errors should be a piece of cake. Au revoir!