Help with Saving of lowest score Only

Subscribe to Help with Saving of lowest score Only 3 posts, 3 voices

 
avatar for Laxaria Laxaria 274 posts

Currently Im using this set of code to save scores:

var score:Number = score;
score=0;
timeInt=setInterval(countUp,15);
function countUp(){
     score ++;
}
function savegame (){
    _root.pos = sharedobject.getLocal("location");
    _root.pos.data.score = _root.score;

}

As you can see, its time based, However, I can’t figure out a way to make it such that if the score for the level is lower than the saved score, then the save function happens. Any ideas?

EDIT: Problem solved. Thanks for the help BigCheese but someone already helped me with it.

EDIT2: Won’t work. =/

 
avatar for BigCheese BigCheese 367 posts
var score:Number = score;
score=0;
timeInt=setInterval(countUp,15);
function countUp(){
     score ++;
}
function savegame (){
    _root.pos = sharedobject.getLocal("location");

    if(_root.score < _root.pos.data.score){
           _root.pos.data.score = _root.score;
    }
}

You could use an if statement to test if it’s less than what has been saved.

 
avatar for skyboy skyboy 163 posts

this is what i have, no clue where the file saves to though… sigh

stop();
var pos:SharedObject;
var score:Number;
if(score==undefined){score=0}
clearInterval(timeInt);timeInt=setInterval(countUp,1);
function countUp(){
     _root.score++;
}
function savegame(){
    trace("savegame called");
    _root.pos =  SharedObject.getLocal("location");
    trace("pos defined");
    var iCheck=_root.pos.data.savedOnce;
    trace("iCheck defined");
    if(!iCheck){
    trace("iCheck not found");
    _root.pos.data.savedOnce=true;
    trace("iCheck set");
    _root.pos.data.score = _root.score;
    _root.pos.flush();
    trace("first score saved");
    }else{
    trace("iCheck found");
    if(_root.score < _root.pos.data.score){
    _root.pos.data.score = _root.score;
    _root.pos.flush();
    trace("score saved");
    }else{
    trace("score higher then found, not saved");}}
    X="score="+score;
}