最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
flash as3 Error: Error #2037 错误提示解决办法
时间:2022-06-28 22:15:56 编辑:袖梨 来源:一聚教程网
Error: Error #2037: 函数调用序列不正确,或前面的调用不成功。
| 代码如下 | 复制代码 |
| at flash.media::Sound/_load() at flash.media::Sound/load() at org.mousebomb.media.musicPlayerV4::Mp3Container/loadMp3() at org.mousebomb.media.musicPlayerV4::Mp3Container/nextMp3() at org.mousebomb.media.musicPlayerV4::MusicPlayer/aC() |
|
经过调查,这个错误的原因是:Sound对象只允许被load一个声音流,即使close()了也不能加载另一个声音.
一旦对某个 Sound 对象调用了 load(),就不能再将另一个声音文件加载到该 Sound 对象中。 若要加载另一个声音文件,请创建新的 Sound 对象。
外国人的解决办法
Sound files load asynchronously in Flash. Listen for the Event.COMPLETE event and in that event handler, add code to check if both are loaded and then play.
an example:
//
| 代码如下 | 复制代码 |
|
Before you load,
|
|
Example: do this:
| 代码如下 | 复制代码 |
|
s = new Sound(req); ///do a bunch of stuff, and at some time later try to load a new mp3 in |
|
You will get
Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.
For each new mp3 you need 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; var mp3s:Array = ["test.mp3","BT - Satellite.mp3"]; var cache:Object = new Object(); playNext_mc.addEventListener(MouseEvent.CLICK, playSound); var s:Sound; function getNextAudioURL():String { //////////// normal audio loading //////////// //////////// use cached audio //////////////// function onSoundFailedToLoad(Event:IOErrorEvent):void { var localSound:Sound = event.target as Sound; |
|
////////////// parse the key mp3 name /////////////////
//NOTE: a cleaner approach way would to be a Proxy that passes arguments along with the event, created during //the listener
| 代码如下 | 复制代码 |
|
var url:String = localSound.url; //////////// cache it //////////////////////// } |
|
Caching Sounds...or anything for that matter
Once you've loaded a Sound(Bitmap etc) it's in memory so if your reusing it (e.g. Sound FX) there's no need to reload it. Here you can use a cache, using the name of the sound as a key, and a CustomEvent to mimic the loaded event, as the default Event target is readonly, so you can't mimic the call coming from the cache. The solution is to override it, and call the listeners directly if you can't redispatch using the original sound. The advantage is the loading event, don't know the difference between the real or loaded. The cache might also be used for offline/online type activities. But of course be aware you're memory useage for caching like this can get large quickly.
| 代码如下 | 复制代码 |
|
package com.troyworks.core.persistance { private var _overriddenTarget:Object; public function CacheEvent(type:String,bubbles:Boolean=false, cancelable:Boolean=false) { } } |
|
相关文章
- 漫蛙漫画官网入口在哪-2026漫蛙最新网址分享与在线阅读方法 03-16
- 钉钉网页版登录首页-钉钉网页版快捷登录入口 03-16
- 2925邮箱官方入口直达-2925邮箱官网一键访问 03-16
- picACG哔咔漫画2026新版手机下载 03-16
- yandex引擎网页版入口-yandex网页版登录入口2026 03-16
- jm漫画网页版免费看-jm漫画国内直接访问 03-16