As3 Error #2037 Functions Called In Incorrect Sequence
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. Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus Copyright 2013 - Mike Chambers
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Functions called in incorrect sequence, or earlier call was unsuccessful up vote 1 down vote favorite in my application, I did some trace statements of a file http://www.mikechambers.com/blog/2009/02/28/error-error-2037-functions-called-in-incorrect-sequence-or-earlier-call-was-unsuccessful/ For example if(oldFile.parent.toString()!=file.parent.toString()) There are some other file print statements , and it seems to encounter this error stated below. But the error does not appear every time. For example i ran my application for 20 times, it will encounter this error once. Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful. at Error$/throwError() at flash.filesystem::File/resolveComponents() at flash.filesystem::File/get parent() flex action share|improve this question asked Mar 8 '12 at 4:46 user1004413 6563719 http://stackoverflow.com/questions/9613035/functions-called-in-incorrect-sequence-or-earlier-call-was-unsuccessful add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted may be you are not checking the existence of the file before calling it. Refer this link might be help full. share|improve this answer edited Jan 25 '14 at 14:12 answered Mar 8 '12 at 5:40 Triode 8,91912138 nope does not work. i tried with the code below ` if(oldFile!=null){ trace("oldFile : "+oldFile.exists.toString()); } ` it still show the error at the trace statement –user1004413 Mar 8 '12 at 11:28 can you paste the complete code here, thanks –Triode Mar 8 '12 at 12:17 Hi, its abit difficult to that, cause there are like few thousand lines of codes. The oldFile is a private variable that is initialize in the whole program. Is this error very common in AS3 ? –user1004413 Mar 8 '12 at 21:52 not like that once we see the code, it will be easy to find out the issue –Triode Mar 9 '12 at 4:44 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service.
is a single use item. Once it's been loaded you can't use it again, regardless if it's the same mp3 or a different http://troyworks.com/blog/2007/09/25/as3-caching-sound-error-2037-functions-called-in-incorrect-sequence-or-earlier-call-was-unsuccessful/ one, or null, you'll get the cryptic error "Functions called in incorrect sequence" Example: do this: s = new Sound(req); ///do a bunch of stuff, and at some time later try to load a new mp3 in s.load(req); You will get Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful. For each new mp3 you need as3 error to create a new Sound object. Note that SoundChannel is like a playhead, more than one of them can be accessing the Sound data, so you can create chorus/echo effects by triggering play() multiple times at different time/offsets. Here's a sound player that cycles through 2 mp3s with no errors, and caches the results. import flash.net.URLLoader; import flash.net.URLRequest; import as3 error #2037 flash.media.Sound; import flash.media.SoundChannel; import flash.events.*; import com.troyworks.core.persistance.CacheEvent; var mp3s:Array = ["test.mp3","BT - Satellite.mp3"]; var cache:Object = new Object(); playNext_mc.addEventListener(MouseEvent.CLICK, playSound); var s:Sound; var _channel:SoundChannel; function getNextAudioURL():String { var curURL:String = mp3s.shift(); mp3s.push(curURL); return curURL; } function playSound(evt:Event = null) { var audioSwfURL:String = getNextAudioURL(); trace("***************************************************************"); trace("playSound " +audioSwfURL); //trace(" attempting to restore " + audioSwfURL + " into AUDIO"); try { if (_channel != null) { //_channel.stop(); //UNCOMMENT ME TO STOP THE PREVIOUS PLAYING TRACK //s.load(); //won't work with progressive //s.close(); //won't work with progressive } if (audioSwfURL != null && cache[audioSwfURL] == null) { //////////// normal audio loading //////////// var req:URLRequest = new URLRequest(audioSwfURL); s = new Sound(); //speaker_mc.display_txt.text ="."; s.addEventListener(Event.COMPLETE, onSoundLoaded); s.addEventListener(IOErrorEvent.IO_ERROR, onSoundFailedToLoad); s.load(req); }else{ //////////// use cached audio //////////////// trace("hitting cache"); var cevt:CacheEvent = new CacheEvent(Event.COMPLETE); cevt.target = cache[audioSwfURL]; onSoundLoaded(cevt); } } catch (err:IOError) { trace(err.toString()); } catch (err:Error) { trace(err.toString()); } } function onSoundFailedToLoad(Event:IOErrorEvent):void { trace("onSoundLoaded **FAILED**"); //speaker_mc.display_txt.text = "!"; } function onSoundLoaded(event:Event ):void { //speaker_mc.display_txt.text = ""; var localSound:Sound = event.target as Sound; ////////////// parse the key mp3 name /////////