Hello the problem i'm experiencing is when I attempt to call javascript function.
Using Jquery @
$("#flashtxtchat").get(0).startTxtChat()
- ArgumentError: Error #2126:
- NetConnection object must be
- connected. at
- flash.net::NetConnection/get nearID()
- at textchat/startChat() at
- Function/http://adobe.com/AS3/2006/builtin::apply()
- at
- flash.external::ExternalInterface$/_callIn()
- at ()
- List item
<![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>
What can be the problem? Thank you I've used a similar implementation for video chat which works flawlessly I just removed all video related functions and only left in text chat now it doesn't work?