views:

166

answers:

1

I am trying to connect to FBJS bridge. It keeps giving me the following error.When I'm opening only one connection and I do not have any other window open.

ArgumentError: Error #2082: Connect failed because the object is already connected.
at flash.net::LocalConnection/connect()
at BabyVille()[C:\Documents and Settings\user\Desktop\babyville\flash\Main Project\src\BabyVille.as:56]

This is my code :

public class fbjsTest extends Sprite
{
    private var connection:LocalConnection = new LocalConnection(); 
    private var connectionName:String = LoaderInfo(root.loaderInfo).parameters.fb_local_connection;
    public function fbjsTest()
    {
        connection.connect(connectionName);
    }
}

That is on the Facebook page if I try to run it locally the following line returns null

LoaderInfo(root.loaderInfo).parameters.fb_local_connection

Any Ideas?

+1  A: 

Beware of cached LocalConnections. If your app is closed incorrectly the connection will still be "connected". Shut down your browser to make sure it's gone. You can alternatively give the connection a random name (if the logic of your app permits it of course). Hope that saves a head-ache !

EDIT :

Hold on, you're not meant to connect this one ! The receiver, (the one handled by the bridge) is the one that is already connected.

Example from FB developer center :

var connection:LocalConnection = new LocalConnection();
var connectionName:String = LoaderInfo(this.root.loaderInfo).parameters.fb_local_connection;

function callFBJS(methodName:String, parameters:Array):void {
    if (connectionName) {
        connection.send(connectionName, "callFBJS", methodName, parameters);
    }
}

callFBJS("document.setLocation", ["http://someurl"]);
Theo.T
I have tried restarting the PC and only running the online link. Still does not work.
Fahim Akhter