00:00
00:00
Newgrounds Background Image Theme

ozziel94 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

saving in flash

3,302 Views | 3 Replies
New Topic Respond to this Topic

saving in flash 2008-01-02 20:32:50


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?

Response to saving in flash 2008-01-02 20:45:20


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 : )


BBS Signature

Response to saving in flash 2008-01-02 20:55:31


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 :(

Response to saving in flash 2008-01-02 22:03:50


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.