首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AS3为什么RTMFP android不能连接到android?

AS3为什么RTMFP android不能连接到android?
EN

Stack Overflow用户
提问于 2012-12-26 00:36:09
回答 1查看 801关注 0票数 1

我正在使用AS3闪存CS6中的netconnection进行连接。当我从我的PC到Android上的应用程序测试swf时,它工作得很好。但当我在两台安卓设备上安装这款应用时,它们无法连接。为什么会这样呢?如果我用我的PC和两个安卓设备进行测试,它也可以工作。我如何才能让它只在两个android设备上工作?

下面是我使用的代码:

代码语言:javascript
复制
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);
 }
EN

回答 1

Stack Overflow用户

发布于 2012-12-26 07:20:22

我建议在开关中添加一个默认的case语句。它可能会也可能不会揭示正在发生的事情:

代码语言:javascript
复制
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);
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14032356

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档