views:

334

answers:

1

Hi, I am trying to create a login system where a user would be able to login inside of one flash game on say, example.com, and then that same login data would be preserved for all the games on example.com and also the games on foo.com and bar.world.com

I am new to shared objects in flash so if anybody knows of a way to do this in either php, as3, html, js (or a mixture of all) then that would be great.

(PS. I would prefer not to use a method that requires a javascript bridge to retrieve cookies as this is impossible for games that are played on game-portal sites where only a swf file is used)

A: 

This is a solution in AS3.

Check out the doc for SharedObject.getLocal(), it's here:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html#getLocal()

When you create the shared object, you give it a name and optionally a 'localPath', the localPath allows you to make it accessible from multiple swfs.

The following code will make the shared object available to all the swfs in that domain.

var so:SharedObject = SharedObject.getLocal('loginInfo', '/');

Sharing a SharedObject between multiple domains is explicitly prohibited by the security model. You might be able to create a swf that takes care of the SharedObject and load it at runtime from example.com. That would work around the security problem.

ablerman
I don't understand what you mean by that last bit,How would mochiads be doing it then? Using their wrapper to encase the actual game and thus the game is technically still on the same domain?
Cal S
There are 2 ways you could do it:1. Load a wrapper from example.com that would then load the game from whereever.com.2. Load the game from wherever.com and within the game, load a login module from example.com. You'd probably have to monkey with some security stuff, but I think it would work.
ablerman