Shared Objects

Is it possible to access the same shared object from different flash movies. I am trying this, and I put the exact same code to access the shared object in the first frame of both movies, but when I update the SO in one of the movies, the other one does not reflect the change. Both movies are in the same folder. Any ideas?

Since it is called a "shared object, I would think that more than one movie could access it, but what do I know. :smirk:

I don’t know if it matters, but here is the code:

// Get the user's name from the cookie
user = SharedObject.getLocal("user_profile");
// If the user has not set up a name, call them Guest. If thay have already set a name, call them that.
if (user.data.userName == undefined) {
    user.data.userName = "Guest";
    user.flush()
    userName = "Guest";
} else {
    userName = user.data.userName;
}
_root.gotoAndStop("done");

Many thanks.

ah…these little known beasts called SO…

well, there’s just a little trick to it, coz every movie will save to it’s own folder, based on it’s url, in the general ā€œshared objectsā€ folder (did you ever check what’s in there…?)…
unless instructed otherwise!

now, young obi wan, to achieve this, how can i? asking you are…?

well, ask no more, simple is the task when the force is with you!
(sorry, just felt like a bit of fun in all these coding questions…thanks for having read this far…so the answer is…i forgot!..joking! :smiley: )

this is the important line:
user = SharedObject.getLocal(ā€œuser_profileā€);
because you can pass it another parameter:
a target folder/ path!

(sharing one of the best kept flash secrets here, better move this to the best of section later! lol )

so: user = SharedObject.getLocal(ā€œuser_profileā€, ā€œ/ā€);
will save all your SO in the main/master directory/folder,
or replace by for example
user = SharedObject.getLocal(ā€œuser_profileā€, ā€œ/testā€);
or whatever…in both movis the same of course!!

happy now?:smirk:

Interesting :slight_smile: I’m rating this.

ah…

so simple, yet so complicated…

many, many thanks.