1

我正在与 AS3 Flash CS6 中的 netconnection 建立连接。当我从我的 PC 测试 swf 到我的 Android 上的应用程序时,它工作正常。但是当我在 2 台 android 设备上安装应用程序时,它们无法连接。这是为什么?如果我用我的电脑和两个安卓设备进行测试,它也可以工作。如何使其仅适用于两个 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);
 }
4

1 回答 1

0

我建议在你的 switch 中添加一个 default 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);
}
于 2012-12-25T23:20:21.523 回答