jess
July 5, 2004, 5:21pm
1
Salut salut !
I create and populate a sharedobject in A.swf, like this :
var myCookie = SharedObject.getLocal(“user_profile”);
if (myCookie.data.firstname == undefined) {
myCookie.data.firstname = “cowboy”;
myCookie.flush();
}
else {
myCookie.data.firstname = “cowgirl”;
myCookie.flush();
}
I want to retrieve this stored data, in B.swf, which is located beside A.swf, like this :
**var myCookie = SharedObject.getLocal(“user_profile”);
myTextfield.text = myCookie.data.firstname;
**
The problem is that I always get “undefined” in place of “cowboy” or “cowgirl”.
:ogre:
What I’m doing wrong ?
thxx a lot
system
July 6, 2004, 10:40am
2
Really no idea guys ?.. :*(
Why can’t I get my sharedobject.data.firstname from that other swf ?
I can’t get it.
Look simple but really can’t get rid of that problem…
system
July 6, 2004, 11:31am
3
Well… me again :hugegrin:
In other terms, DOES ANYBODY MANAGE TO READ SHAREDOBJECTS THAT HAV BEEN CREATED IN A SWF, FROM WITHIN **ANOTHER **SWF (but placed beside the first one) ?
In order to share the SharedObject between different swf movies, you need to set the path in your getLocal statement after the name of the SharedObject. In this case, just set the path to the current folder:
A.swf:
var myCookie = SharedObject.getLocal("user_profile","/");
if (myCookie.data.firstname == undefined) {
myCookie.data.firstname = "cowboy";
myCookie.flush();
}
else {
myCookie.data.firstname = "cowgirl";
myCookie.flush();
}
B.swf:
var myCookie = SharedObject.getLocal("user_profile","/");
myTextfield.text = myCookie.data.firstname;
Simple as that !
it works now, thxx for your answer **Jerryscript **:thumb: