0

I have a Flash app set up in a Facebook canvas and it's using ExternalInterface to call a JavaScript function, then calling a Flash function from JavaScript when the first function completes:

Flash objects & vars:

this.dBug.text += "\ngetting user albums...\n"
var usrAlbums:Array = new Array();
var pageLimit:Number = 48;
var pageOffset:Number = 0;
this.dBug.text += "\ttotal albums before call: " + usrAlbums.length + "\n";

Callback function:

this.dBug.text += "\tadding getAlbumResponse callback to ExternalInterface\n";
ExternalInterface.addCallback('getAlbumResponse', getAlbumResponse);
this.dBug.text += "\tcreating getAlbumResponse callback\n";
function getAlbumResponse(rtrn):void{
    dBug.text += "\nresponding to album get...\n";
    this.dBug.text += "\t\t\tresult: " + rtrn['data'] + "\n";
    var album:Array = rtrn['data'];
    this.dBug.text += "\t\tadding objects to usrAlbums array...\n";
    for(prop in rtrn['data']){
        usrAlbums.push(new Array(album[prop], new Array()));
        this.dBug.text += "\t\t\tadded " + album[prop] + ", new Array() to usrAlbums array\n";
        ++pageOffset;
        this.dBug.text += "\t\t\t\talbumCount:  " + pageOffset + "\n";
    }
    this.dBug.text += "\tcheck for more albums\n";
    if(pageOffset == pageLimit){
        getAlbum(++pageOffset, pageLimit);
    }else{
        this.dBug.text += "\t\ttotal albums after call: " + usrAlbums.length + "\n";
    }
}

ExternalInterface call function to JavaScript:

function getAlbum(offset:Number, limit:Number){
    this.dBug.text += "\t\tcalling swfGetAlbum(/me/albums?offset=" + offset + "&limit=" + limit + ")...\n";
    ExternalInterface.call('swfGetAlbum', '/me/albums?offset=' + offset + '&limit=' + limit);
}

Call the EI function:

getAlbum(pageOffset, pageLimit);

Javascript on hosting page:

function swfGetAlbum(graph){
    console.log('swfGetAlbum(' + graph + ')');
    FB.api(graph, function(response){ console.log(response); swfGetAlbumCallback(response); });
}
var swfGetAlbumCallback = function(response){
        console.log(response);
    console.log(document.getElementById('app-root'));
            document.getElementById('app-root').getAlbumResponse(response);
}

Everything works fine on my Mac under my Facebook account on Chrome, Safari, Opera and Firefox. It also works under the same browsers on my testing PC, and additionally on Internet Explorer.

For some reason when my friend tests the app using his Facebook account, he gets an error when the Javascript code initiates the callback and attempts to run document.getElementById('app-root').getAlbumResponse(response);. He is testing on his own PC with the same browsers, all producing the same result. Under Chrome, the error reads as Uncaught Error: Error calling method on NPObject.

To make things more interesting; this error appears when he is testing the app on MY machine using his Facebook account and does not happen when I test the app on HIS machine using my Facebook account.

I've also been able to test the app with two other Facebook accounts. One of them on my Mac under Safari and another on my friend's wife's PC using Chrome. Neither of those tests had the error.

The target version for Flash for this app is at least v11 (all tested machines/browsers have the latest Flash player,) and inserted into the page using swfobject 2.

I am totally baffled by this behavior. Anyone come across something like this?

Thanks in advance!

Eric
  • 2,061
  • 8
  • 28
  • 37

1 Answers1

0

Total shot in the dark that we even tried this...

To conform with Facebook's https, we're on a secure server. We checked under my friend's settings to discover that the https browsing setting was unchecked. Once it was checked again, everything worked.

Eric
  • 2,061
  • 8
  • 28
  • 37