错误#2044:未处理的NetStatusEvent

时间:2014-08-28 21:17:49

标签: actionscript-3 flash

我不确定为什么我会收到以下错误。你能否告诉我在我的舞台上成功播放rtmp流所需的代码变化? 错误:

  

NetConnection.Connect.Success错误#2044:未处理的NetStatusEvent:。   level = error,code = NetStream.Play.StreamNotFound at   main / attachnetstream()[/ Users / user / Desktop / ojotha / main.as:24]调试   会议终止。

package  {
    import flash.display.MovieClip;
    import flash.net.*;
    import flash.events.NetStatusEvent;
    import flash.media.Video;

    public class main extends MovieClip {
    public var streamserver:String="rtmp://216.245.200.114/live";
    public var streamname:String="shomoy";
    public var netconnection:NetConnection=new NetConnection();

        public function main() {
            netconnection.connect(streamserver);
            netconnection.addEventListener(NetStatusEvent.NET_STATUS, attachnetstream);




        }
        public function attachnetstream(event:NetStatusEvent):void{
            trace(event.info.code);
            switch (event.info.code) {
                case "NetConnection.Connect.Success":
                var netstream:NetStream=new NetStream(netconnection);
                var video:Video=new Video();
                video.attachNetStream(netstream);
                netstream.play(streamname);
                video.height=480;
                video.width=640;
                addChild(video);

                break;
                case "NetStream.Play.StreamNotFound":
                trace("stream not found");
                break;
            }
                }


            }

    }

1 个答案:

答案 0 :(得分:-1)

您也应该将NetStatusEvent事件侦听器添加到您的流中。

stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

查看docs

您可能还需要设置另一个事件侦听器,即使它是空的以防止其他一些运行时错误。

stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);