<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http:
layout="absolute"
creationComplete="initSharedObject()">
<mx:Script>
<![CDATA[
import flash.net.SharedObject;
public var sharedObj:SharedObject;
private function initSharedObject():void{
sharedObj = SharedObject.getLocal("myTasks");
if (sharedObj.size > 0)
textareaTasks.text=sharedObj.data.tasks;
}
public function localconnectionHandler(msg:String):void {
textareaTasks.text= textareaTasks.text + msg + "\n";
}
private function clearTasks(event:MouseEvent):void {
textareaTasks.text="";
}
private function saveTasks(event:MouseEvent):void {
sharedObj.data.tasks = textareaTasks.text;
sharedObj.flush();
}
private function deleteSavedTasks(event:MouseEvent):void {
sharedObj.clear();
}
]]>
</mx:Script>
<mx:Panel horizontalCenter="0" verticalCenter="0.5" verticalGap="15"
paddingLeft="20" paddingRight="20" paddingBottom="20" paddingTop="20"
height="300">
<mx:Label text="Your tasks are..."/>
<mx:TextArea id="textareaTasks"
top="20" left="20" right="20" bottom="20"
width="100%" height="100%"/>
<mx:HBox>
<mx:Button id="btnClearTasks" click="clearTasks(event)"
label="Clear Tasks"/>
<mx:Button id="btnSaveTasks" click="saveTasks(event)"
label="Save Tasks to Shared Object"/>
<mx:Button id="btnDeleteSavedTasks" click="deleteSavedTasks(event)"
label="Delete Saved Shared Object Tasks"/>
</mx:HBox>
</mx:Panel>
</mx:Application>
It seems that Flex saves the data in different locations for different browsers.
Try the sample above as follows:
1) run the sample in IExplorer and save tasks (e.g. "ie tasks").
2) open a new IE, and run the sample. You'll get "ie tasks".
3) open a new Firefox browser, and run the sample. You'll get blank tasks. Save tasks (e.g. "ff tasks").
4) open a new Firefox - you'll get "ff tasks".
5) open a new IE - you'll get "ie tasks".
thanx,