adobe startus text chat broken @ connection setup

时间:2010-08-10 22:27:16

标签: flex flash actionscript-3 flex4 flash-builder

你好我遇到的问题是当我试图调用javascript函数时。

使用Jquery @

$("#flashtxtchat").get(0).startTxtChat()
  
      
  • ArgumentError:错误#2126:      
        
    • NetConnection对象必须
    •   
    • 连接。在
    •   
    • flash.net::NetConnection/get nearID()
    •   
    • 在textchat / startChat()
    •   
    • 功能/ http://adobe.com/AS3/2006/builtin::apply()
    •   
    •   
    • flash.external :: ExternalInterface的$ / _呼唤()
    •   
    • at()
    •   
    • 列表项
    •   
  •   
<![CDATA[
    import flash.events.*;
    import flash.external.*;
    import flash.net.*;
    import flash.system.*;

    import mx.containers.*;
    import mx.controls.*;
    import mx.core.*;
    import mx.events.*;
    import mx.styles.*;
    import mx.utils.*;

    private var netConnection:NetConnection;
    private var sendStream:NetStream;
    private var receiveStream:NetStream;
    private var strangerPeerID:String;

    public function init() : void
    {
        var url:* = FlexGlobals.topLevelApplication.url;
        var serverName:* = URLUtil.getServerName(url);
        if (!serverName.match(/(localhost|127.0.0.1)$/))
        {
            return;
        }
        ExternalInterface.addCallback("startTxtChat", this.startChat);
        ExternalInterface.addCallback("gotStrangerPeerID", this.gotStrangerPeerID);
        ExternalInterface.addCallback("sendMsg", this.sendMsg);
        ExternalInterface.addCallback("stopTxtChat", this.stopChat);
        ExternalInterface.call("flashtxtChat_init");
        return;
    }// end function

    public function startChat() : void
    {
        if (this.netConnection)
        {
            ExternalInterface.call("flashtxtChat_gotNearID", this.netConnection.nearID);
        }
        else
        {
            this.netConnection = new NetConnection();
            this.netConnection.addEventListener(NetStatusEvent.NET_STATUS, this.netConnectionHandler);
            this.netConnection.connect("rtmfp://stratus.rtmfp.net/removed-removed/");
        }
        return;
    }// end function

    public function gotStrangerPeerID(param1:String) : void
    {
        var _loc_3:NetStream = null;
        this.strangerPeerID = param1;
        var _loc_2:int = 0;
        while (_loc_2 < this.sendStream.peerStreams.length)
        {

            _loc_3 = this.sendStream.peerStreams[_loc_2];
            if (_loc_3.farID != this.strangerPeerID)
            {
                _loc_3.close();
            }
            _loc_2++;
        }
        this.receiveStream = new NetStream(this.netConnection, this.strangerPeerID);
        this.receiveStream.play("textchat");
        this.receiveStream.client = this;///temp added by me
        //this.strangerVideo.attachNetStream(this.receiveStream);
        return;
    }// end function

    public function sendMsg(msg: String) : void
    {
        sendStream.send("recvMsg", msg);
    }

    public function recvMsg(msg: String) : void
    {
        ExternalInterface.call("recvMsg", msg);
    }

    public function stopChat() : void
    {
        this.strangerPeerID = null;
        return;
    }// end function

    public function netConnectionHandler(event:NetStatusEvent) : void
    {
        var c:Object;
        var event:* = event;
        switch(event.info.code)
        {
            case "NetConnection.Connect.Success":
            {
                c = new Object();
                c.onPeerConnect = function (param1:NetStream) : Boolean
                {
                    if (strangerPeerID == null)
                    {
                        return true;
                    }
                    return param1.farID == strangerPeerID;
                };// end function
                this.sendStream = new NetStream(this.netConnection, NetStream.DIRECT_CONNECTIONS);
                this.sendStream.client = c;
                this.sendStream.publish("textchat");
                ExternalInterface.call("flashtxtChat_gotNearID", this.netConnection.nearID);
                break;
            }
            case "NetConnection.Connect.Failed":
            {
                this.netConnection = null;
                ExternalInterface.call("flashCb_errorConnectingToStratus");
                break;
            }
            case "NetConnection.Connect.Closed":
            {
                this.netConnection = null;
                this.sendStream.close();
                this.sendStream = null;
                if (this.receiveStream)
                {
                    this.receiveStream.close();
                    this.receiveStream = null;
                }
                break;
            }
            default:
            {
                break;
            }
        }
        return;
    }// end function
]]>
</mx:Script>

可能是什么问题?谢谢,我已经使用了类似的视频聊天实现,它完美无缺地删除了所有与视频相关的功能,只留下文字聊天现在它不起作用了?

1 个答案:

答案 0 :(得分:0)

检查更新后允许本地p2p重置的播放器设置