?
Solved

SharedObject.getLocal

Posted on 2010-01-11
2
Medium Priority
?
546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

770 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