//ERRORS ON EXPORT Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone. error=ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.
In googling these errors, I've found a lot of people saying you must have a function handling the AsyncErrorEvent, as FMS needs to use it, whether or not it does anything. I've read the same thing about onBWDone. However, I've yet to find a widely used way of satisfying either of those obligations that works with our code. And I've also not seen any example that satisfies BOTH of those problems.
NOTE:Using Actionscript 3 is imperative
//OUR CODE...NOTE: We need to pass an argument(movie) to this function. //That's why it's in a standard function residing inside the .fla //instead of a class on an included .as file. Also, a number of other //functions/variables need to be fired when onNetStatus() is fired.
function init(movie:String):void {
videoConnection = new NetConnection();
videoConnection.connect("rtmp://path/to/app");
videoConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetConnectStatus);
function onNetConnectStatus(e:NetStatusEvent):void {
videoStream = new NetStream(videoConnection);
video.video.attachNetStream(videoStream);
videoStream.play(movie);
videoStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
videoStream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
}
function onNetStatus(e:NetStatusEvent):void {
if (e.info.code == "NetStream.Play.Start") {
//DO SOMETHING ON PLAY
}
}
function onAsyncError(event:AsyncErrorEvent):void {
//IGNORE...ONLY FOR FMS USE
}
}
halp?
the fms server automatically invokes onBWDone when it has completed detecting the bandwidth capabilities of the requesting client. It also calls a bunch of other methods too, like onLastSecond() and there's a few others i can't remember off the top of my head.
basically the netconnection instance needs a client class to handle all of these method invocations. You can either have a separate class that houses these methods, or you can pass the root timeline to the net connection and implement them there. for instance:
videoConnection = new NetConnection(); videoConnection.connect("rtmp://path/to/app"); videoConnection.client = this videoConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetConnectStatus);
/* you now need to have a function declared called onBWDone() */
function onBWDone(...args):void { trace ( "onBWDone! : " + args ); }
similarly you can say:
videoConnection.client = new SpecialVideoConnectionClient();
where SpecialVideoConnectionClient is a class that just has
public function onBWDone ( ...args ):void {
}
public function onLastSecond ( ...args ):void {
}
/*... etc */
hope it helps. It's first thing monday morning here so i may not be as eloquent as i would've liked. 
cheers,
A.