| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jul 2002
Posts: 11
|
I have created a Shared Object in "a.swf". I can read and write to it -no problem, but how do I access it from a movie "b.swf".
If in "b.swf" I use: so = sharedobject.getLocal("savedPrefs"); myTextfield.text=so.data.thevar; ...Nothing happens! Or when trying to indicate the path to the movie which created the SharedObject: so = sharedobject.getLocal("savedPrefs","/dir/a.swf"); myTextfield.text=so.data.thevar; -same result. Anybody got this to work? Again, I need to access my SharedObject not from the movie I created it in but from a DIFFERENT one. Any help would be much appreciated |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
If you checkout the structure of .sol file storage on your PC you will see that each domain gets one directory, and each directory in the URL becomes a subdirectory, finally the last directory contains a directory named after your original SWF.
I don't remember reading anywhere that SOL files can only be accessed from the same file that created them but a test I ran just then proved this may be the case. a.swf contains this: ActionScript Code:
ActionScript Code:
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
Join Date: Jul 2002
Posts: 11
|
Yes I klnow, this is exactly my problem.
MM documentation says you have to pass path parameter to the getLocal function so it can access so created by a different movie. I tried - didn't work: so = sharedobject.getLocal("savedPrefs","/dir/a.swf"); myTextfield.text=so.data.thevar; Anyone? |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Yeah I read that too but the actual documentation doesn't make it quite clear. I figured it out from an example on Macromedia's site which states the dependencies a bit better though. If you want to access a.swf's SOL from b.swf, you need to define the path not only in b.swf but also in a.swf. So this work:
a.swf: ActionScript Code:
Dynamic text field with variable 'field' and: ActionScript Code:
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#5 |
|
Registered User
Join Date: Jul 2002
Posts: 11
|
Thanks! The "/" thing worked!
I tried to use path like "/dir" and "dir/b.swf" in both movies as in the MM example and it didn't. Couldn't think that the solution was so simple ![]() |
|
|
|
|
|
#6 |
|
Registered User
Join Date: Jul 2003
Location: Belgium
Posts: 7
|
sorry to bring up this old thread again, but it was linked to from the SO tutorial, and seemed the best place to ask my question:
how do you set the path for a local movie? i'm working on a small RCA, and want to store the data in an SO. they are stored in the directory 'localhost', but i don't get the optional parameter to set a subdir to work. |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Are you asking how to store them in a specific directory on the webserver or on the client? I'm not sure how to do it on the webserver. The argument for the client is stil bound by the domain but it allows you to create SOs which are accessible by files from the same domain. You can't create one above the domain level directory, as that would be accessible accross domains, which is a security risk.
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#8 |
|
Registered User
Join Date: Jul 2003
Location: Belgium
Posts: 7
|
i was referring to offline applets, the SO's all come in the folder localhost, but i want to create a subfolder for them.
|
|
|
|
|
|
#9 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
If you don't provide a path they will appear in a sub-directory under localhost with the same name as the SWF (from memory)... But I don't think you can specify a directory for them all other than root. Then again, I've only use SOs when Iw as writing that tute, so I'm not an expert.
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#10 |
|
Registered User
Join Date: Sep 2003
Posts: 3
|
OK, the above example makes perfect sense to me. I tested it and successfully got "b.swf" to read the SO set up by "a.swf." In fact, I had a button in "a.swf" open a new window that contained "b.swf" and it worked, so I guess SO's can be read by multiple .swf's at one time.
The problem is that I tried a little modification that I can't get to work. I created an input text field in "a.swf" whose contents I want to save in the SO and have show up when b.swf loads. I can't get it to work. Do I need to create a button to manually "flush" the data? Any thoughts greatly appreciated! ![]() |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Access the same sharedObject | LeonJebb | ActionScript 2.0 | 2 | 02-01-2005 08:15 AM |
| path confusion. try to access movie clip inside another one | knorickus | ActionScript 2.0 | 8 | 04-07-2004 05:32 PM |
| Print command doesn't work from external movie. | vladc77 | ActionScript 1.0 (and below) | 1 | 05-20-2003 02:40 AM |
| Looping Movie B until Movie A stops | ajlazarte | Other Flash General Questions | 1 | 03-24-2003 07:16 AM |
| load a movie into a movie but then load an other movie into that loaded movie ? | lesaint | ActionScript 1.0 (and below) | 1 | 03-23-2002 10:16 PM |