1

I'm making a connection with netconnection in AS3 Flash CS6. It works fine when I test the swf from my PC to the app on my Android. But when I install the app on 2 android devices they don't connect. Why is that? If I test with my PC and the two android devices it works too. How can I make it work with only the two android devices?

Here's the code I'm using:

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);
 }
hh_s
  • 33
  • 7
  • Note that the `NetStautusEvent` gets dispatched with messages like `NetGroup.Connect.Failed` and `NetGroup.Connect.Rejected` and possibly other useful messages. It might be helpful to add a `default` case statement in your `switch` to see what kinds of messages you get when its not working. – Sunil D. Dec 25 '12 at 20:10
  • The switch enters this "NetGroup.Connect.Success" in both androids apps. If I start the swf on my PC they are all working. Isn't it possible with only the Android devices? – hh_s Dec 25 '12 at 22:08
  • Great! You might be getting other NetStatusEvent's after the connect message. The switch statement you have shown isn't checking for anything else. Just some advice for trouble shooting... It may not pan out but any additional details you can get from those events might be insightful – Sunil D. Dec 25 '12 at 22:27
  • I've added NetGroup.Connect.Failed and NetGroup.Connect.Rejected to the switch but it enters the Success statement. – hh_s Dec 25 '12 at 22:42
  • That is expected since you said it connects successfully. All I'm getting at is that there may be other messages that get dispatched after the successful connection attempt. I only mentioned the reject/fail messages as an example :) I'll post an example of what I'm suggesting below... – Sunil D. Dec 25 '12 at 23:13

1 Answers1

0

I suggest adding a default case statement to your switch. It may or may not shed some light on what is happening:

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);
}
Sunil D.
  • 17,983
  • 6
  • 53
  • 65
  • Okay, thanks. I've added the default but nothing traces. I guess the code must be alright since it's working on both Androids as soon as I open the swf version on my PC. Seems like there's missing something when it's a connection from Android to Android only. – hh_s Dec 26 '12 at 09:01