Skip to main content
Inspiring
December 18, 2016
Answered

Save/Loading

  • December 18, 2016
  • 1 reply
  • 268 views

Good afternoon users, I have a question about creating a simple database for storing variable values in dynamic text:

// Var

score.text = "" + qnt_score.toString();

var so:SharedObject = SharedObject.getLocal("yourso", "/");

// Actions

You_Score += 1;

so.data.highscore = You_Score;

so.flush();

trace("Give a score!")

I tried to run this way, however, unsuccessfully, the score is not saved (or not loaded), the attempt was to make the score save automatically, and load from the click of a button.

Can anybody help me? I'm grateful now!

This topic has been closed for replies.
Correct answer kglad

how do you know it wasn't saved?

usually you'd use:

var so:...etc

if(so.data.highscore){

//do something.  eg, You_Score=so.data.highscore

} else {

You_Score=0;

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 18, 2016

how do you know it wasn't saved?

usually you'd use:

var so:...etc

if(so.data.highscore){

//do something.  eg, You_Score=so.data.highscore

} else {

You_Score=0;

}