# Saving code question

**URL:** <https://forum.kirupa.com/t/saving-code-question/245582>\
**Category:** Uncategorized\
**Created:** [December 1, 2007, 7:16am UTC](https://forum.kirupa.com/t/saving-code-question/245582 "2007-12-01T07:16:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonthelion](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@leonthelion](https://forum.kirupa.com/u/leonthelion)\
**Post date:** [December 1, 2007, 7:16am UTC](https://forum.kirupa.com/t/saving-code-question/245582/1 "2007-12-01T07:16:55Z")

</div>

Heres my code:

```php
 
function savegame(){
 myLSO = SharedObject.getLocal("Xin_Chapter1");
 if(myLSO.data.myObj == undefined){ // No object exists
     trace("Saved Game");
 }
 else{
     trace("Overwrote Saved Game");
 }
     myObj = {}; 
     myObj.objArray = new Array();
  myObj.objArray[0] = hp;
  myObj.objArray[1] = mp;
  myObj.objArray[2] = maxhp;
  myObj.objArray[3] = maxmp;
  myObj.objArray[4] = atk;
  myObj.objArray[5] = def;
  myObj.objArray[6] = sp;
  myObj.objArray[7] = maxsp;
  myObj.objArray[8] = xp;
  myObj.objArray[9] = maxxp;
  myObj.objArray[10] = maxatk
  
  myLSO.data.myObj = myObj;
}

function loadgame(){
 myLSO = SharedObject.getLocal("Xin_Chapter1");
 if(myLSO.data.myObj == undefined){ // No object exists
  trace("No Saved Game");
 }
 else{
  trace("Loaded Game");
  hp = myLSO.data.myObj.objArray[0];
  mp = myLSO.data.myObj.objArray[1];
  maxhp = myLSO.data.myObj.objArray[2];
  maxmp = myLSO.data.myObj.objArray[3];
  atk = myLSO.data.myObj.objArray[4];
  def = myLSO.data.myObj.objArray[5];
  sp = myLSO.data.myObj.objArray[6];
  maxsp = myLSO.data.myObj.objArray[7];
  xp = myLSO.data.myObj.objArray[8];
  maxxp= myLSO.data.myObj.objArray[9];
  maxatk=myLSO.data.myObj.objArray[10];
  } 
}

```

My question is I used to have all the variables (atk, def, hp, sp, etc.) as \_root. type variables, I have changed them to \_global. variables so I could have a movieclip with the dynamic text inside it. Okay so the real question is: would I have to change any of the code in any of the functions because of this? Thanks

OFF TOPIC:  
would it be possible to do this?

1. make dynamic text
2. put the variable health in the variable box
3. put this code on the frame:\_root.health.text=\_global.hp  
Would it be possible to do that? Thanks again
