mike chambers | about

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

Saturday, February 28, 2009

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:

[SWF] FileWatcher2.swf - 1,040,015 bytes after decompression
Error: Error #2037: Functions called in incorrect sequence, or earlier  
call was unsuccessful.
	at flash.filesystem::File/_exists()
	at flash.filesystem::File/get exists()
	at com.adobe.air.filesystem::FileMonitor/set file()[/Users/mesh/src/ 
as3corelib/src/com/adobe/air/filesystem/FileMonitor.as:138]
	at com.adobe.air.filesystem::FileMonitor()[/Users/mesh/src/as3corelib/ 
src/com/adobe/air/filesystem/FileMonitor.as:94]
	at FileWatcher2/onFileSelect()[/Users/mesh/Documents/Flex Builder 3/ 
FileWatcher2/src/FileWatcher2Class.as:32]</code>

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