我正在使用AS3闪存CS6中的netconnection进行连接。当我从我的PC到Android上的应用程序测试swf时,它工作得很好。但当我在两台安卓设备上安装这款应用时,它们无法连接。为什么会这样呢?如果我用我的PC和两个安卓设备进行测试,它也可以工作。我如何才能让它只在两个android设备上工作?
下面是我使用的代码:
var nc:NetConnection;
var group:NetGroup;
nc = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
nc.connect("rtmfp:");
function netStatus(event:NetStatusEvent):void{
switch(event.info.code){
// The connection attempt succeeded
case "NetConnection.Connect.Success":
setupGroup();
break;
// The NetGroup is successfully constructed and authorized to function.
case "NetGroup.Connect.Success":
break;
// A new group posting is received
case "NetGroup.Posting.Notify":
trace("notify");
break;
case "NetGroup.SendTo.Notify":
trace("notify received");
break;
// user joins?
case "NetGroup.Neighbor.Connect":
break;
}
}
// Create a group
function setupGroup():void {
// Create a new Group Specifier object
var groupspec:GroupSpecifier = new GroupSpecifier("test");
// Enable posting
groupspec.postingEnabled = true;
//groupspec.routingEnabled=true;
// Specifies whether information about group membership can be exchanged on IP multicast sockets
groupspec.ipMulticastMemberUpdatesEnabled = true;
// Causes the associated NetStream or NetGroup to join the specified IP multicast group and listen to the specified UDP port.
groupspec.addIPMulticastAddress("225.225.0.1:30000");
// Constructs a NetGroup on the specified NetConnection object and joins it to the group specified by groupspec.
group = new NetGroup(nc,groupspec.groupspecWithAuthorizations());
// Set the NET_STATUS event listener
group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);
}发布于 2012-12-26 07:20:22
我建议在开关中添加一个默认的case语句。它可能会也可能不会揭示正在发生的事情:
switch (event.info.code)
{
case "NetConnection.Connect.Success":
// etc... Not showing orig code
break;
// rest of the case statements here
// then lastly add this:
default:
trace(event.info.code);
}https://stackoverflow.com/questions/14032356
复制相似问题