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.