Example of saving app state

Does anyone have an example of this to share ?

This is my class for saving and retreiving top ten score in this app: http://itunes.apple.com/app/haunted-house-the-game/id396419936
import flash.net.SharedObject;
public class HighScoreShared {
var highScores: SharedObject;
var cookie_name: String;
public function HighScoreShared(cookie_name:String) {
this.cookie_name = cookie_name;
highScores = SharedObject.getLocal(this.cookie_name);
if (highScores.data.scores==undefined){
//trace("highscore undefined... create a new array");
defaultScores();
// testing
//reset();
//defaultScores();
//trace("highScores.data.scores: "+highScores.data.scores);
public function reset(){
highScores.clear();
public function defaultScores(){
highScores.data.scores = new Array();
for(var i:uint=0;i<10;i++){
highScores.data.scores.push({name:"none",value:(10-i)*100});
public function getHighScores():Array{
highScores = SharedObject.getLocal(this.cookie_name);
return highScores.data.scores;
public function getNamesFormatted():String{
var returnStr:String="";
for(var i:uint=0;i<10;i++){
returnStr+=highScores.data.scores[i].name+"\n";
return returnStr;
public function getValesFormatted():String{
var returnStr:String="";
for(var i:uint=0;i<10;i++){
returnStr+=highScores.data.scores[i].value+"\n";
return returnStr;
public function getTopOne():Number{
return highScores.data.scores[0].value;
public function getLastOne():Number{
return highScores.data.scores[9].value;
public function setNewScore(thename:String,thescore:int){
if (thename.length>10) thename = thename.substring(0,10);
highScores = SharedObject.getLocal(this.cookie_name);
if (highScores.data.scores==undefined){
//trace("error undefined!");
}else{
for(var i:uint=0;i<10;i++){
//trace("i: "+i+" value: "+highScores.data.scores[i].value);
if (highScores.data.scores[i].value <=thescore){
//trace("found the right place");
for (var j:uint=9;j>i;j--){
trace("j: "+j+" value: "+highScores.data.scores[j].value+" <--" +highScores.data.scores[j-1].value);
highScores.data.scores[j].name = highScores.data.scores[j-1].name;
highScores.data.scores[j].value= highScores.data.scores[j-1].value;
highScores.data.scores[i].name = thename;
highScores.data.scores[i].value = thescore;
//trace("i: "+i+" value: "+highScores.data.scores[i].value+" <--thescore: " +thescore);
return;
Hope this can help.
Emanuele

Similar Messages

  • Windows domain controller in a virtual machine: how dangerous is saving its state for a short period of time?

    I have a Windows Server 2012 R2 virtualization cluster. All the hosts are connected to an external storage system, and virtual machines' files are stored on external volumes (CSVs). All the hosts and virtual machines are a part of the same AD domain
    (mixed Windows Server 2012 RTM / 2008 R2 domain controllers). All the domain controllers are running in the virtual machines on the hosts of this cluster.
    To prevent problems when all the hosts are turned off and then on simultaneously (for example, because of a power failure) all the domain controller VM files has been placed on local disks of the virtualization hosts (not on the Cluster Shared
    Volumes). As Hyper-V services don't depend on other Windows Server services (except its networking components), it means that my domain controllers can always start, providing the virtualization host can start at all. However, it also means
    that those DCs cannot be (quickly) migrated to other hosts while their current hosts are being rebooted. So if I need to reboot a virtualization host to install new updates, for example, I have to shut down the corresponding DC, reboot the host
    and wait for the DC to finish cold boot and come back online. It means some interruption of service for our users, which, in turn, requires me to perform the reboots late in night.
    The downtime can be significantly decreased by saving the state of the VM in which the DC is running. However, all the articles I've found on the Internet strongly recommend against it. I'm trying to understand why this recommendation was issued in the first
    place. However, I'm unable to find a clear explanation. I've found some statements that saving state of a DC can cause serious AD replication problems because of tombstoning, and that the password of a DC computer account may be changed
    while the DC itself stays in the saved state, which could prevent the DC from connecting to the domain after its state has been restored. However, those considerations are non-significant when we discuss a short-time
    (5 to 10 minutes) saved state.
    I work with AD and virtualization long time, and I fail to see any danger in saving state of a DC for several minutes. In my opinion, after its state has been restored it would simply replicate all the AD changes from other DCs, and that's all.
    What's your opinion?
    Evgeniy Lotosh
    MSCE: Server infractructire, MCSE: Messaging

    Hello,
    as stated in "http://technet.microsoft.com/en-us/library/virtual_active_directory_domain_controller_virtualization_hyperv(v=ws.10).aspx"
    Operational Considerations for Virtualized Domain Controllers
    Domain controllers that are running on virtual machines have operational restrictions that do not apply to domain controllers that are running on physical machines. When you use a virtualized domain controller, there are some virtualization software features
    and practices that you should not use:
    Do not pause, stop, or store the
    saved state of a domain controller
    in a virtual machine for time periods longer than the tombstone lifetime of the forest and then resume from the paused or saved state.
    This may sound as it is supported to store it for shorter times and use it.
    BUT recommendation also from the Hyper-V Program manager in
    http://blogs.msdn.com/b/virtual_pc_guy/archive/2008/11/24/the-domain-controller-dilemma.aspx recommends against using them.
    Also best practices
    http://blogs.technet.com/b/vikasma/archive/2008/07/24/hyper-v-best-practices-quick-tips-2.aspx
    Best regards
    Meinolf Weber
    MVP, MCP, MCTS
    Microsoft MVP - Directory Services
    My Blog: http://blogs.msmvps.com/MWeber
    Disclaimer: This posting is provided AS IS with no warranties or guarantees and confers no rights.
    Twitter:  

  • I have 2 apple id's with different apps and data saved under each.  It's very annoying so now I want to create a new id with my primary email address I use now.  If I do that is there any way to transfer all my saved apps and app data like game saves etc?

    I have 2 apple id's with different apps and data saved under each.  It's very annoying so now I want to create a new id with my primary email address I use now.  If I do that is there any way to transfer all my saved apps and app data like game saves etc so I don't lose all of that information and can easily switch to a singular apple id?

    Apple does not transfer content bought with one Apple ID to another Apple ID. Apple will not merge two Apple IDs.
    If most of your content was bought with the Yahoo! Apple ID but you now want the Gmail address for your Apple ID, the trick will be to change the address used for the Yahoo ID with the Gmail address. However, to do that you must first free the Gmail address from that other Apple ID. Use the instructions from Apple to substitute another address that is not used as an Apple ID for your Gmail address in the Apple ID with the Gmail address. Then, when the Gmail address is no longer used in an Apple ID, you can use the same instructions to substitute the Gmail address for the Yahoo address in the Apple ID with the Yahoo address.
    Changing the email address you use for your Apple ID -
    http://support.apple.com/kb/HT5621

  • Is there any way that you can delete APPS that come on the iPad? For example, the stock app, can you delete that or is it permanently on there?

    Is there any way that you can delete APPS that come on the iPad 2 when you buy it? For example, the stock app, can you delete that or is it permanently on there?

    You cannot delete the preinstalled apps on the iPad. You can check by tapping and holding down on the icon until it wiggles. If no X appears, you cannot delete it.
    Move it to another screen or bury it in a folder called" Stuff I don't Want"

  • Example Oracle Forms app viewable online?

    Hi,
    Can anyone point me to an example Oracle Forms app available online using IE and Jinitiator?
    I don't have the environment to run demo code, and am not interested in the code itself, I simply want to run an app in IE to try to replicate a conflict between jinitiator and an IE Add-in that I'm responsible for.
    thanks,
    - Rory

    Our browser Add-on is only available for IE, and the problem only happens when the add-on is running. So we've not tried Firefox but it wouldn't help unfortunately.
    - Rory

  • GreenPower battery saving app and "my Xperia" service

    I have recently migrated from an iPhone to Sony Z1 on EE, and I have been pretty happy with this transition.
    The only thing I have noticed is that the Stamina mode was not performing as I was hoping, so I downloadd a third party battery saving app called GreenPower. This app has significantly increased the battery life of Z1 to the point where I'm only charging the phone every few days.
    The nature of this GreenPower app is to automatically disable WIFI and Mobile Data while the screen is switched off, unless you specify a whitelist of apps to keep data enabled if the apps are active. Unfortunately, this mechanism stopped "my Xperia" service from being able to locate my phone.
    What is the "exact" mechanism in which "my Xperia" service locates my phone? Is there a process on my phone that polls, or push from my Xperia service?
    Any suggestions on the list of processes to add to my white list of apps in GreenPower? I have added "my Xperia" app to this list but this did not help.

    MyXperia needs the data to be on or wifi, third party apps will create issues with other apps, there isn't a way around it, other than uninstall such apps. 
    "I'd rather be hated for who I am, than loved for who I am not." Kurt Cobain (1967-1994)

  • Examples of bigger apps?

    hi, I'm having a frustrating time... can anybody help?
    I know VC++ fairly well in an amateurish way and I really don't understand how Java apps of any size work... do they use the application-document-view architecture which seems to underpin most VC++ projects? It is proving very difficult to find non-trivial Java apps unless they are way over my head... Where can I get hold of a basic Java application skeleton?
    Also, no books online or otherwise seem to explain how you go about splitting things up into discrete classes and yet letting them communicate adequately with one another... or what is the "ancestor" or indeed "parent" of a component... is it a JFrame?... where is all this documented? Where are examples of larger apps? Of the process by which they are developed?
    Also, because so much code is taken up with just getting on top of the GUI and the layout managers, programs of any significance seem to grow at a frightening rate meaning that you soon do in fact have to split things up...
    And then you find a passing comment in a doc saying "keep your GUI code separate from the business logic"... OK, care to spend a bit of time on that?
    Please somebody recommend an online resource...??
    Mike

    this is a crosspost of http://forum.java.sun.com/thread.jsp?forum=54&thread=157095

  • How to get to folder in /Library/Saved Application State/com.adobe.flashplayer.installmanager.savedState

    I have a file saved in a folder which according to a find ?/ -name "" search is located here /Library/Saved Application State/com.adobe.flashplayer.installmanager.saved
    But I can't browse through this folder structure in Finder (I have run command to allow me to see hidden folders if that is required).
    Please can someone help me to find out how to get to this file. It's an excel spreadsheet.
    Thank you

    When I try to save another excel file that I have also opened from a password protected zip file, the automatic folder selected is "wzQL.8t0UHS". When I try to save a file with exactly the same name as the file that is missing into the folder "wzQL.8t0UHS" it tells me that the file already exists and asks if I want to replace it.
    My assumption was therefore that it was some kind of cache where the file is intact.
    When I've done a search on the name of the file I am looking for in Finder, I do not find the file.

  • CC App states Download error on Apps page. Press retry to try again

    On Mac 10.8.5
    CC App states Download error on Apps page. Press retry to try again
    Really frustrating. It worked for 2 days and since then I keep getting this error. There are no firewall issues etc.

    Hi ParagonLtd,
    Please try to apply the updates manually: http://prodesigntools.com/adobe-cc-updates-direct-links-mac.html.
    Kindly follow the very important instructions before download.
    Regards,
    Romit Sinha

  • When I try to down load any apps the screen shows -example you tube app can't down load this time. This is appearing every time on the screen and options are Done/reentry please do my favour.

    When I try to down load any apps the screen shows -example you tube app can't down load this time. This is appearing every time on the screen and options are Done/reentry please do my favour. 

    This query seems to be related to Edge Code. you can get help from this forum.
    Also EdgeCode doesn't have troubleshooting page but you can get help from Brackets trouble shooting page.

  • How to prevent saving apps on hdd ?

    Hello all,
    as a proud owner of new Macbook air I have very limited storage in it. As I can see, my apps in iTunes library eat about 45GB od space. How can I prevent saving apps on my drive? I can easily download them from clowd, so why keep them on expensive SSD.
    Thank you for any help.

    Roopavathy wrote:
    Hi,
    I want to prevent users from (right click & save images) saving images in my website. How can i do this?
    Simple, you can't.
    The internet is based off of the idea of downloading files from remote servers into your browser for viewing (file sharing). If they can see your image, they have already downloaded it to their computer. The final steps of making that temporary file a permanent addition to their hard drive are simple and unavoidable.
    It would probably be much better (easier and less counter-intuitive for the end user) to examine "why" you are attempting to bar your viewers from saving the information your are presenting to them on your site and working on whether it actually makes sense to place that info on your site in the first place.
    If you want to protect content from "random internet bad guys" consider password protecting it so only those users who are given the username and password can access it. That's definitely not the way to present normal online info, but would make sense for things like photography sites (showing customers proofs of photos before they decide on packages to purchase) or similar.
    If password protection doesn't make sense for your site, the only way to keep viewers from copying your info is to keep it off the internet all together.

  • I am unable to print bank statements and saved bank statements with my Mac.

    When I updated Firefox to 5.0, everything worked out fine printing the bank statements and saved bank statements. Now, I am unable to print statements from one bank only. No problem with statements from other banks. Where is the hang-up?

    You should try to start in safe mode which runs a file check. You hold the shift key down during a start up till there is a progress bar towards thr bottom of the screen. This start will take a longer time than normal. In safe mode try the functioins you are having problems with to see if there is an improvement. Some links below to read.
    http://support.apple.com/kb/ht1564
    http://support.apple.com/kb/ht1455

  • Health App Stats Resetting Each Day

    I got the iPhone 6 the day it was released.  I immediately started using the new Health app.  I added the basics, birthday, age, sex, weight, and I added the "Steps" and "Walking + Running Distance" to the dashbaord.  I notice they automatically started tracking my steps.  So I went for a jog, it tracked that also.  Awesome, so far so good.  But the next day it was all gone.  It doesn't matter if I select "Day / Week / Month / Year" at the top top, the stats are always the same, the only show the current day.  I've checked each day since I've got the phone, each day it seems to start over.  Why is all the previous data disappearing?  Thanks!

    http://apple.stackexchange.com/questions/146827/ios-8-health-app-stats-resetting -each-day

  • Applescript to delete caches and folders in Saved Application State

    I don't know if this can be done, but I'd like to write and Applescript to perform these functions:
    1) to delete caches from all 3 cache folders and the ~/Library/Saved Application State folder
    2) to run at  logout, shutdown or startup (any of those is fine)
    3) to run  with admin credentials already provided
    Can this be done?
    Thanks.

    You're not going to find anything useful in that folder. To clear an application's saved state, launch it while holding down the shift key. I very strongly advise you not to use the shell unless you're sure you know what you're doing.

  • Saving session state in database table rather in websever for Ordering App

    Hi all,
    Ours is a ordering application (telecomm) domain.
    Currently, we are storing user sessions data (Order shopping cart session data) in middle tier (iPlanet web server) which inturn consumes lot of memory resources.
    Shopping cart could be in MBs if order is a huge business order.
    So in order to not to overtax web server (middle tier), we are thinking of storing session data directly in a database table to relieve the overhead on web server and make use of database for storage.
    I read that APEX (html db) is already using this "single metadata table" approach for session data management. But we are not using HTML DB to really look into.
    Can some one advise how to go about storing "user session data" directly in a "database table" for both storage and retrieval purposes instead of storing it in "webserver".
    How does this "metadata table" structure looks like. Is it more generic ?
    Really appreciate your time and help/suggestions.

    Joel,
    Thanks for your response. sorry, i meant to say that "the current application does not use APEX but will look into it".
    To build this is an utterly non-trivial exercise. Oh - it may not be so hard to save session state to a table when you POST a page. But you may want to reference this in many places, and it's a question of can you change all of these references to indirect references from session state in your application.In order to free up the load on webserver, we want to maintain session management in database. Could you please explain the above little more :
    How do we maintain the "user session" with "database table" ?
    Do we need to store "session data" at java object level or by page in database table ? How does the structure of this "metadata table" looks like.
    Thanks for your time.

Maybe you are looking for