Skip to main content
Inspiring
October 16, 2014
Answered

SWF Can't Access Network

  • October 16, 2014
  • 23 replies
  • 1230 views

Hello, so I'm making a Flash game, and I got LAN connection to work, but for some reason when I upload the SWF to a website and try to access it, I get the whole "do you want to allow this to access the internet?" conformation box, except I can't actually change any of its settings. It's all blank and when I click on it nothing happens. Here is a screenshot: 7170db2f8b7108246a3729102a711700

I tried opening it on multiple computers, all of them get the same issue. Does anyone have any ideas why this is happening?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

Still no luck, I get this error:

ArgumentError: Error #2126: NetConnection object must be connected.

    at flash.net::NetGroup/ctor()

    at flash.net::NetGroup()

    at GameNewConnection_fla::MainTimeline/click_lan_multiplayer()

This is what I have set up:

var nc:NetConnection = new NetConnection();

var message:Object = {varName:'p1_up',value:p1_up};

nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);

const SERVER:String = "rtmfp://p2p.rtmfp.net/bc2e309a9922d17c5c93d209-67472b5c1565/";

const DEVKEY:String = "bc2e309a9922d17c5c93d209-67472b5c1565";

nc.addEventListener(NetStatusEvent.NET_STATUS,connect);

nc.connect(SERVER+DEVKEY);

var multiplayer = "off";

var m_switch1 = "false";

var m_switch2 = "false";

var group:NetGroup;

function click_lan_multiplayer(event:MouseEvent):void

{

    var groupSpecifier:GroupSpecifier = new GroupSpecifier("TheGroup");

    groupSpecifier.postingEnabled = true;

    groupSpecifier.routingEnabled = true;

    // Allow peers to join the group automatically.

    groupSpecifier.serverChannelEnabled = true;

    group = new NetGroup(nc,groupSpecifier.groupspecWithAuthorizations());

    multiplayer = "on";

    if (m_switch1=="false")

    {

        group.sendToAllNeighbors( {varName: 'm_switch1', value: m_switch1});

        m_switch2 = "false";

        m_switch1 = "true";

        gotoAndStop(101);

    }

    else

    {

        m_switch2 = "true";

        gotoAndStop(101);

    }

}

On another frame right on the layer above it I have this:

//Network

import flash.display.MovieClip;

import flash.events.NetStatusEvent;

import flash.net.NetConnection;

import flash.net.NetGroup;

import flash.net.GroupSpecifier;

import flash.net.NetGroupReplicationStrategy;

var obj:Object = {};

var p1x;

var p1y;

var p2x;

var p2y;

function netStatus(event:NetStatusEvent):void

{

    switch (event.info.code)

    {

        case "NetConnection.Connect.Success" :

            setupGroup();

            break;

        case "NetGroup.Connect.Success" :

            break;

        case "NetGroup.Neighbor.Connect" :

            break;

        case "NetGroup.Posting.Notify" :

            break;

        case "NetGroup.SendTo.Notify" :

            switch ( event.info.message.varName )

            {

                case 'p1y' :

                    p1y = event.info.message.value;

                    break;

                case 'p1x' :

                    p1x = event.info.message.value;

                    break;

                case 'm_switch1' :

                    m_switch1 = event.info.message.value;

                    break;

                case 'p1_up' :

                    p1_up = event.info.message.value;

                    break;

                case 'p1_down' :

                    p1_down = event.info.message.value;

                    break;

                case 'p1_left' :

                    p1_left = event.info.message.value;

                    break;

                case 'p1_right' :

                    p1_right = event.info.message.value;

                    break;

                case 'p1_attack' :

                    p1_attack = event.info.message.value;

                    break;

                case 'p1_block' :

                    p1_block = event.info.message.value;

                    break;

                case 'p2y' :

                    p2y = event.info.message.value;

                    break;

                case 'p2x' :

                    p2x = event.info.message.value;

                    break;

                case 'p2_up' :

                    p2_up = event.info.message.value;

                    break;

                case 'p2_down' :

                    p2_down = event.info.message.value;

                    break;

                case 'p2_left' :

                    p2_left = event.info.message.value;

                    break;

                case 'p2_right' :

                    p2_right = event.info.message.value;

                    break;

                case 'p2_attack' :

                    p2_attack = event.info.message.value;

                    break;

                case 'p2_block' :

                    p2_block = event.info.message.value;

                    break;

            }

            break;

            break;

        case "NetGroup.Neighbor.Connect" :

            break;

    }

}

function connect(e:Event):void

{

    group.sendToAllNeighbors(obj);

    if (m_switch2=="true")

    {

        group.sendToAllNeighbors( {varName: 'p1_up', value: p1_up});

        group.sendToAllNeighbors( {varName: 'p1x', value: p1x});

        group.sendToAllNeighbors( {varName: 'p1y', value: p1y});

        group.sendToAllNeighbors( {varName: 'p1_down', value: p1_down});

        group.sendToAllNeighbors( {varName: 'p1_left', value: p1_left});

        group.sendToAllNeighbors( {varName: 'p1_right', value: p1_right});

        group.sendToAllNeighbors( {varName: 'p1_attack', value: p1_attack});

        group.sendToAllNeighbors( {varName: 'p1_block', value: p1_block});

        p1x = p1.x;

        p1y = p1.y;

        p2.x = p2x;

        p2.y = p2y;

    }

    if (m_switch1=="true")

    {

        if (m_switch2=="false")

        {

            group.sendToAllNeighbors( {varName: 'p2x', value: p2x});

            group.sendToAllNeighbors( {varName: 'p2y', value: p2y});

            group.sendToAllNeighbors( {varName: 'p2_up', value: p2_up});

            group.sendToAllNeighbors( {varName: 'p2_down', value: p2_down});

            group.sendToAllNeighbors( {varName: 'p2_left', value: p2_left});

            group.sendToAllNeighbors( {varName: 'p2_right', value: p2_right});

            group.sendToAllNeighbors( {varName: 'p2_attack', value: p2_attack});

            group.sendToAllNeighbors( {varName: 'p2_block', value: p2_block});

            p2x = p2.x;

            p2y = p2.y;

            p1.x = p1x;

            p1.y = p1y;

        }

    }

}

function setupGroup():void

{

    var groupspec:GroupSpecifier = new GroupSpecifier("test");

    groupspec.postingEnabled = true;

    groupspec.routingEnabled = true;

    groupspec.ipMulticastMemberUpdatesEnabled = true;

    groupspec.addIPMulticastAddress("225.225.0.1:30000");

    group = new NetGroup(nc,groupspec.groupspecWithAuthorizations());

    group.addEventListener(NetStatusEvent.NET_STATUS,netStatus);

}

The "m_switches" are meant to determine who is P1 and P2 when two peers are connected.

It just seems no matter what, if I have that "sendtoallneighbors" thing put into the code, it gives me an error.


you must be calling click_lan_multiplayer before your group is defined.

in your netStatus function you should be defining your group when

event.info.code==  "NetConnection.Connect.Success":

check my P2P class.

23 replies

kglad
Community Expert
Community Expert
October 16, 2014

click file>publish settings>swf>local playback security>access local files only.

Inspiring
October 16, 2014

It was already set to that, no change. I also tried changing it to "access network only" but that didn't do anything either.

kglad
Community Expert
Community Expert
October 16, 2014

what's the url of your embedding html file?