今天遇到了个问题,呵呵!不过已经解决了,网上资料挺多的,就给大家分享下!
FMS3+AS3 onBWDone回调问题解决
问题:
Error #2044: 未处理的 AsyncErrorEvent:。 text=Error #2095: flash.net.NetConnection 无法调用回调 onBWDone。 error=ReferenceError: Error #1069: 在 flash.net.NetConnection 上找不到属性 onBWDone,且没有默认值。
解决方法
在AS文件的类函数中添加:
1.添加 nc.client = this; (nc 为NetConnection 实例)
2.添加函数: public function onBWDone ():void{}
完整代码如下
package { import flash.display.Sprite; import flash.events.NetStatusEvent; import flash.net.NetConnection; import flash.net.Responder; /** * ... * @author Asher LO */ public class ControlFMS extends Sprite { private var nc:NetConnection; private var rs:Responder;//NetConnection Result value public function ControlFMS():void { nc = new NetConnection(); rs = new Responder(onSuccess, onFailed); nc.connect("rtmp://localhost/firstFMS"); nc.client = this; nc.call("sayHelloWorld", rs, "HelloWorld"); nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatesHandler); } private function onSuccess(rs:Object):void { trace("Success "+rs.toString()); } private function onFailed(rs:Object):void { //ootrace("Failed "+rs.description); trace("Failed "+rs.toString()); } private function onNetStatesHandler(event:NetStatusEvent):void { trace(event.info.code); } public function onBWDone():void { } } }