?
Solved

SharedObject.getLocal

Posted on 2010-01-11
2
Medium Priority
?
552 Views
Last Modified: 2012-05-08
I am trying to store some data in a "SharedObject". However i must be doing somthing wrong.

1. Writing the data i fist swf file.
2. Lising the data i second swf file.

In the second file i get "so.data.test" = "undefined".

Can anyone see, what i am doing wrong.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="200" height="200" creationComplete="onCC()">
<mx:Script>
	<![CDATA[
		import flash.net.SharedObject;

		private function onCC() : void {
			var so:SharedObject = SharedObject.getLocal("test");
			so.data.test = "mydata";
			so.flush();	
		}
	]]>
</mx:Script>

</mx:Application>


------------- NEW FILE -------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="200" height="200" creationComplete="onCC()">
<mx:Script>
	<![CDATA[
		import flash.net.SharedObject;

		private function onCC() : void {
		var so:SharedObject = SharedObject.getLocal("test");
		myText.text = "Lidt " + so.data.test;
		}
	]]>
</mx:Script>
	<mx:Text x="10" y="10" id="myText" color="#000000"/>
	<mx:Text x="10" y="38" text="Text" id="myText2"/>
	
</mx:Application>

Open in new window

0
Comment
Question by:kbnordvest
2 Comments
 
LVL 14

Expert Comment

by:TanLiHao
ID: 26289470
Sorry but this is a restriction of the Flash Player Security sandbox but you can't access the same SharedObject instance using different .swf names.

A way to circumvent this is almost difficult, and will only work if both .swfs can access local data. You use a URLLoader to load the .swf file and read the data by following the format specifications. That may be a little too hard and a waste of time.

Second way is to use SharedObject.getRemote, unfortunately for this you need to use Flash Media Server.

Third and last way I know of, is to use FileReference to read and write files. Though it requires user interaction and you can't just save a file silently like you do with  SharedObject.

Let me know which choice you are going to go with. If you are going with the first choice, just to warn you first I will not help you with that because that's way too much work.
0
 

Accepted Solution

by:
kbnordvest earned 0 total points
ID: 26415402
I ended up using browser cookies in stead. They work great!

Se this : http://myflex.wordpress.com/2008/11/12/actionscript-cookie-util/

0

Featured Post

The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question