Mike Chambers

code = joy

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

with 5 comments

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]

 

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.

Written by mikechambers

February 28th, 2009 at 2:35 am

Posted in General

5 Responses to 'Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful'

Subscribe to comments with RSS or TrackBack to 'Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful'.

  1. That would be:

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

    File.desktopDirectory is not a constructor but a static reference.

    Isaac Rivera

    28 Feb 09 at 7:07 am

  2. @Isaac

    Good catch. That will teach me to copy and past without testing first.

    I fixed the error.

    mike

    mikechambers

    2 Mar 09 at 12:49 am

  3. AIR Error #2037: “Functions called in incorrect sequence, or earlier”…

    After a short quiet period I’m back today to tell you something about the AIR file object. While deploying a new version of my application I ran into some problems on other systems. AIR threw the error #2037: “Functions called in incorrect sequence, …

    The IT Kraut

    1 Oct 09 at 2:18 am

  4. Hi All,
    it’s an old post but I add my contribute.
    If you want add a particular file path you can solve this error with:

    var f:File = new File();
    f.nativePath = “filepath”

    if you use resolvePath it gives you an error, setting nativepath everything works well

    luca mezzalira

    20 Sep 10 at 12:28 pm

  5. My 2 cents

    In case someone encounter this problem with Sound class, don`t forget – each time you load some file, you need new instance of Sound class. If you`l call sound.load(..) 2 times, event with sound.close() between calls, you`l get discussed error .

    Rodislav Moldovan

    23 Feb 11 at 6:57 am

Leave a Reply