A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: How do I save and load variables?

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Posts
    12

    Question How do I save and load variables?

    I have about ten different boolean variables I need to save and load with a button.
    I have read a few posts and could not figure out how to do it, so I am sorry for posting
    a question that has been asked before.

  2. #2
    Junior Member
    Join Date
    Aug 2009
    Posts
    3
    im not really a pro at this but i'll try

    in AS2

    Code:
    var mySO:SharedObject = SharedObject.getLocal("sharedname");
    sharedname is just a name you choose under wich to save on the device
    Code:
    soInitHandler = function(so:SharedObject){
    var1 = mySO.data.so1;
    var2 = mySO.data.so2;
    }
    var1 is a normal variable, mySO.data.so1 is the saved data in de library

    Now to change (save) the values
    Code:
    mySO.data.so1 = var1;
    mySO.data.so2 = var2;
    mySO.flush();
    the "mySO.flush()" sends the data to the shared object library

    and add at end

    Code:
    SharedObject.addListener("sharedname", soInitHandler);

  3. #3
    Junior Member
    Join Date
    Apr 2008
    Posts
    12
    Thank you very much, this is useful. However I do not understand how to load these variables once they are saved.

    **edit** Never mind, I understand. I can get it to work. Thanks a lot for your help. **edit**
    Last edited by killer1390; 08-22-2009 at 04:04 PM. Reason: I figured it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center