Connection between FB and Flash in a browser page

45 views
Skip to first unread message

Arkadianen

unread,
Jun 26, 2011, 9:53:53 AM6/26/11
to facebook-actionscript-api
I am working on a Flash game http://alexgblog.com/?p=772
I want to make available Facebook actions from inside the game, like
getting the user ID or publishing to wall.
Do I need to use JavaScript in a browser page to pass the
authentification params to SWF ? The SWF is on some browser page, for
example on game portal. Or I can access the Facebook parameters
directly from the SWF?
I dont realy understand the authentification flow in facebook-
actionscript-api.
Thanks !

Trevor

unread,
Jun 30, 2011, 11:44:58 AM6/30/11
to facebook-actionscript-api
Take a look at the FlashWebExample at
http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Examples_1_6_1.zip
It shows you how to initialize the library, login to facebook, and
make calls to get and post data.

On Jun 26, 7:53 am, Arkadianen <arkadia...@gmail.com> wrote:
> I am working on a Flash gamehttp://alexgblog.com/?p=772

Arkadianen

unread,
Jul 6, 2011, 7:15:12 AM7/6/11
to facebook-actionscript-api
Thanks Trevor

In example FlashWebExample we can see in the <head>

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript" src="http://connect.facebook.net/
en_US/all.js"></script>
</head>

So the JS script is required.
I am making a game, which will be distributed on portals and I have no
access to HTML code from there.

Can I call from Flash a function like this:
"
var url:URLRequest = new URLRequest( "
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= 'http://connect.facebook.net/en_US/all.js';
document.getElementById('theHeader').appendChild(script)
top.attachScript " );
navigateToURL(url, "_self")
"
?
Will it work?
Did anyone try to master this functionality?
Is there any way to use FB from Flash, without access to initial HTML,
like on Flash game portals?

On Jun 30, 6:44 pm, Trevor <rovertn...@gmail.com> wrote:
> Take a look at the FlashWebExample athttp://code.google.com/p/facebook-actionscript-api/downloads/detail?n...

Trevor

unread,
Jul 7, 2011, 12:07:19 PM7/7/11
to facebook-actionscript-api
The api assumes you have control over the HTML. If you're posting to
portals, you're basically at their mercy when it comes to embedding
your SWF properly and importing the right scripts. And I don't think
your suggestion would be the best because game portals probably
wouldn't like the idea of your SWF injecting HTML elements into the
current page (no matter how good your intentions are). Facebook
requires that we use JS to authenticate the user for web apps, however
you can authenticate with Facebook.mobileLogin for mobile apps (which
doesn't required JS), but this requires PHP to serve the SWF your app-
secret.

Arkadianen

unread,
Jul 8, 2011, 3:35:51 AM7/8/11
to facebook-actionscript-api
Games portals always insert swf in frames so its secure to inject
HTML.
So is it possible to use a code like this:
"
var url:URLRequest = new URLRequest( "
var script=
document.createElement('script');
script.type= 'text/javascript';
script.src= 'http://connect.facebook.net/
en_US/all.js';

document.getElementById('theHeader').appendChild(script)
top.attachScript " );
navigateToURL(url, "_self")
" ?
and to initialise the external Facebook JS library?

Trevor

unread,
Jul 11, 2011, 6:01:30 PM7/11/11
to facebook-actionscript-api
I don't know. You'll just have to try it and see. What's preventing
you from trying?

allandt bik-elliott (thefieldcomic.com)

unread,
Jul 14, 2011, 1:05:35 PM7/14/11
to facebook-act...@googlegroups.com
would you be better off using ExternalInterface?

--
You received this message because you are subscribed to the Google Groups "facebook-actionscript-api" group.
To post to this group, send email to facebook-act...@googlegroups.com.
To unsubscribe from this group, send email to facebook-actionscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/facebook-actionscript-api?hl=en.


Arkadianen

unread,
Jul 28, 2011, 4:14:23 AM7/28/11
to facebook-actionscript-api
> would you be better off using ExternalInterface?

No, external interface is awailable only if you have some JS on page.
And I want to add JS to page from within Flash. Though after you add
JS from within Flash, you can us ExternalInterface also.

> > I don't know. You'll just have to try it and see. What's preventing
> > you from trying?

Yea, I will make it but a bit later, now I just dont have time.
Thanks anyway

On Jul 14, 8:05 pm, "allandt bik-elliott (thefieldcomic.com)"
<alla...@gmail.com> wrote:
> would you be better off using ExternalInterface?
>
Reply all
Reply to author
Forward
0 new messages