mike chambers | about

Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful

I am doing some work on writing FlexUnit test cases for the FileMonitor class which I have added to as3corelib. Once I wrote the test, I got the following error, which didnt make a lot of sense to me at first:

The error is thrown when trying to access a property of the File class (as well as FileReference) before the class has been initialized with a file path. Specifically, the File and FileReference classes must be initialized to reference a file path, before their properties can be accessed.

For example, this will cause the error:

var f:File = new File();
trace(f.exists());

This will not cause an error:

var f:File = File.desktopDirectory;
trace(f.exists());

Anyway, just wanted to post it here in case anyone else runs into the issue.

twitter github flickr behance