Saving and lodaing flash game

Ok well… my idea here is to have a save button that saves you data, or an auto save function either one. Then when you start your game, have a load button that loads the data and takes you to the corresponding level.

For the save button code I have this.


on(release){
savefile.data.levelnum= _root.levelnum;
savefile.flush();
}

And the load button code is.


on(release){
var savefile = SharedObject.getLocal("test");
_root.levelnum = savefile.data.levelnum;
}
if (savefile.data.levelnum == undefined ){ 
_root.gotoAndStop("level1")

Now the only problem with this is I don’t know how to actually implement it. For instance it saving the levelnum equal to 4 then when it loads having it go to the fourth level.