# Help with shared objects/variables from external file

**URL:** <https://forum.kirupa.com/t/help-with-shared-objects-variables-from-external-file/329325>\
**Category:** flash\
**Created:** [August 14, 2012, 10:30am UTC](https://forum.kirupa.com/t/help-with-shared-objects-variables-from-external-file/329325 "2012-08-14T10:30:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![astonvilla65](https://avatars.discourse-cdn.com/v4/letter/a/b9bd4f/32.png) [@astonvilla65](https://forum.kirupa.com/u/astonvilla65)\
**Post date:** [August 14, 2012, 10:30am UTC](https://forum.kirupa.com/t/help-with-shared-objects-variables-from-external-file/329325/1 "2012-08-14T10:30:37Z")

</div>

Hey,

please forgive my lack of knowledge on this, I have been trying to create foundations for a 4 team based application that will record scores based on user input.

I will try and explain as best i can. This is my script that I wish to use to create foundations:

```auto
 
var rommell:Object = new Object();
rommell.team = "rommell";
var rommellb:Object = new Object();
rommellb.team = "rommellb";

team = "rommell";
rom_btn.onRelease = function(){
    team_txt.text = rommell.team;
}
romb_btn.onRelease = function(){
    team_txt.text = rommellb.team;
}

```

This should create two of the four (team) objects I need, I can get the objects displaying the team name in the team\_txt text field from the button presses. I now wish to read from an external file to read differing variables for each object. I have 2 (test) text fields that should display a number in the text field.

```auto
var externalData:LoadVars = new LoadVars();   
  externalData.onLoad = function(){
    field1_txt.text = externalData.rommell1;
    field2_txt.text = externalData.rommell2;
}
externalData.load("stats.txt")

```

This is an example of what my external data file is, its just a notepad in the same dir as the FLA.

@rommell  
@rommell1=60  
@rommell2=9  
@rommellb1=5  
@rommellb1=4

I have tried adding field1\_txt.text=Number(externalData.rommell1);. This hasn’t worked nor has the above code. Once i have got this working I can then add further variables that I need. Once done I want to try and create an if statement on each team button release such as:

```auto

rom_btn.onRelease = function() {   
team_txt.text = rommell.team;
    if (team_txt.text == "rommell") {
        field1_txt.text = externalData.rommell1;
        field2_txt.text = externalData.rommell2;
    }

```

and the same for the other 4 buttons:

```auto

romb_btn.onRelease = function() {
    team_txt.text = rommellb.team;
    if (team_txt.text == "rommellb") {
        field1_txt.text = externalData.rommellb1;
        field2_txt.text = externalData.rommellb2;
    }

```

Is this going to achieve what i want? I wanted to use shared objects but I’m not advanced enough to fully use them, please advise on what you guys think the best way to do this is.

Any help in getting this step set-up is massively appreciated, I’m getting stressed with this and it’s my 4th or 5th go. Ahhhh.

Many Thanks
