# Refreshing a shared object question

**URL:** <https://forum.kirupa.com/t/refreshing-a-shared-object-question/328767>\
**Category:** flash\
**Created:** [June 14, 2012, 5:53pm UTC](https://forum.kirupa.com/t/refreshing-a-shared-object-question/328767 "2012-06-14T17:53:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamber\_luke](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@chamber\_luke](https://forum.kirupa.com/u/chamber_luke)\
**Post date:** [June 14, 2012, 5:53pm UTC](https://forum.kirupa.com/t/refreshing-a-shared-object-question/328767/1 "2012-06-14T17:53:57Z")

</div>

Ok I have 2 swf files running simultaneously. One takes in the information and the other displays it.

So far I have gotten both swf files to recognize the shared object but I need the display swf to refresh when the input file gets updated.

I added a timer into the code to continually reload the shared object every second and it traces just fine…BUT…

…with both files open I can see that the display file only sees the state of the shared object that it loaded when first opened and does not refresh…wha?

here’s the code:  
import flash.net.SharedObject;  
import flash.events.MouseEvent;

var saveDataObject:SharedObject;  
var currentScore:int;  
var myTimer:Timer = new Timer(1000); // 1 second  
myTimer.addEventListener(TimerEvent.TIMER, runMany);  
myTimer.start();

function runMany(event:TimerEvent):void {  
init();//this goes directly beneath the variables

function init():void{//call once to set everything up  
saveDataObject = SharedObject.getLocal(“SwimulatorResults”,"/"); // give the data a location  
currentScore = 0;//start with 0

if(saveDataObject.data.savedScore == null){//checks to see if there is a save  
trace(“No saved data yet”);//if there isn’t it says this  
saveDataObject.data.savedScore = currentScore; //…set the savedscore to 0  
} else {  
trace(“Save Data Found.”);//if we find data  
loadData();  
}  
updateScoreText();//finally update the text field  
}

function addScore(e:MouseEvent):void{  
currentScore += 1;//add 1 to the score  
updateScoreText();//update the text field  
}

function saveData(e:MouseEvent):void{  
saveDataObject.data.savedScore = currentScore;// set the saved score to the current score  
trace(“Data Saved!”);  
saveDataObject.flush();// immediately save to the local drive  
trace(saveDataObject.size);// this will show the size of the save file in bytes

}

function loadData():void{  
currentScore = saveDataObject.data.savedScore;//set the current score to the saved score  
trace(“Data Loaded!”);  
}

function updateScoreText():void  
{  
txtScore.text = ("Score: " + currentScore);//set the text property of the txtScore  
trace(“Score text updated”);

}  
}

Now the tricky part is that it traces the messages “Save Data Found!” , “Save data loaded”, and “Text updated” but the text has does not update.
