Hey all... I know you can save a score in flash but what if I have a MC called health and it is on frame 6, when you save the game, come back later and load, it is still at frame 6. Could I save something like that and how?
Hey all... I know you can save a score in flash but what if I have a MC called health and it is on frame 6, when you save the game, come back later and load, it is still at frame 6. Could I save something like that and how?
At 1/2/08 08:32 PM, connemaraproductions wrote: Hey all... I know you can save a score in flash but what if I have a MC called health and it is on frame 6, when you save the game, come back later and load, it is still at frame 6. Could I save something like that and how?
function saveGame(){
myLSO = SharedObject.getLocal("uniqueName");
if(myLSO.data.myObj == undefined){ // No object exists
trace("Saved Game");
}
else{
trace("Overwrote Saved Game");
}
myObj = {};
myObj.objArray = new Array();
myObj.objArray[0] = lives;
myObj.objArray[1] = score;
myLSO.data.myObj = myObj;
}
function loadGame(){
myLSO = SharedObject.getLocal("uniqueName");
if(myLSO.data.myObj == undefined){ // No object exists
trace("No Saved Game");
}
else{
trace("Loaded Game");
lives = myLSO.data.myObj.objArray[0];
score = myLSO.data.myObj.objArray[1];
}
}
then put
loadGame();
on your load button
and
saveGame();
on your save button
im sure you can change the code around to fit what you need : )
thanks but I'm having a hard time trying to get it to work :\
let me explain...i have an MC called "stats"
inside it are MC's called "health" and "happiness"
how do i get health and happiness to save on whatever frame they are on?
sorry, i'm not very good with this advanced actionscript stuff :(
At 1/2/08 08:45 PM, proflashsional wrote:
myLSO.data.myObj = myObj;
myLSO.data.flush();
I do believe you left out the bolded part.