Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 07-07-2002, 09:12 PM   #1
ajuly
Registered User
 
Join Date: Jul 2002
Posts: 11
Default SharedObject -how do I access it from another movie?

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
ajuly is offline   Reply With Quote
Old 07-08-2002, 10:02 AM   #2
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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:
mySO = SharedObject.getLocal("test"); mySo.data.name = "Joes"; success = mySO.flush();
b.swf contains a dynamic text field with variable 'field' and this:
ActionScript Code:
mySO = SharedObject.getLocal("test"); field = mySo.data.name;
If you run a.swf first it stores the SOL file correctly but b.swf can't read it. If you delete a.swf from your server and rename b.swf to 'a.swf', all of a sudden it works. So to sumarise I think the file names have to be the same.
__________________
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.
Jesse is offline   Reply With Quote
Old 07-08-2002, 10:10 AM   #3
ajuly
Registered User
 
Join Date: Jul 2002
Posts: 11
Default

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?
ajuly is offline   Reply With Quote
Old 07-08-2002, 02:51 PM   #4
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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:
mySO = SharedObject.getLocal("test","/"); mySo.data.name = "Joes"; success = mySO.flush();
b.swf:
Dynamic text field with variable 'field' and:
ActionScript Code:
mySO = SharedObject.getLocal("test", "/" ); field = mySo.data.name;
Thanks to this example at MM: http://www.macromedia.com/support/fl...s/local_so.htm
__________________
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.
Jesse is offline   Reply With Quote
Old 07-08-2002, 09:12 PM   #5
ajuly
Registered User
 
Join Date: Jul 2002
Posts: 11
Default

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
ajuly is offline   Reply With Quote
Old 07-14-2003, 08:50 AM   #6
Cyberdigitus
Registered User
 
Join Date: Jul 2003
Location: Belgium
Posts: 7
Default

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.
Cyberdigitus is offline   Reply With Quote
Old 07-15-2003, 02:13 AM   #7
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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.
Jesse is offline   Reply With Quote
Old 07-17-2003, 10:46 AM   #8
Cyberdigitus
Registered User
 
Join Date: Jul 2003
Location: Belgium
Posts: 7
Default

i was referring to offline applets, the SO's all come in the folder localhost, but i want to create a subfolder for them.
Cyberdigitus is offline   Reply With Quote
Old 07-18-2003, 08:35 AM   #9
Jesse
Administrator
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: Australia
Posts: 8,612
Default

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.
Jesse is offline   Reply With Quote
Old 09-17-2003, 06:03 PM   #10
tic-tac
Registered User
 
Join Date: Sep 2003
Posts: 3
Default

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!
tic-tac is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 10:10 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.
You Rated this Thread: