# Simple problem, I hope!

**URL:** <https://forum.kirupa.com/t/simple-problem-i-hope/6178>\
**Category:** flash\
**Created:** [October 1, 2002, 11:07am UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178 "2002-10-01T11:07:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![lynott](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@lynott](https://forum.kirupa.com/u/lynott)\
**Post date:** [October 1, 2002, 11:07am UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/1 "2002-10-01T11:07:37Z")

</div>

Hi,

I have a simple problem, I hope!

I am reading a variable from a text file

tr\_1 = East&

into a dynamic text field tr\_1.

When I try and trace the value of the text field I cannot get the value I have just read in.

i.e.

loadVariablesNum("./correctTrains.txt", 1);

var count = 0;

trace (“dyn text =” + this.tr\_1 );

‘correctTrains.txt’ looks like this

tr\_1=East&

The thing is I can see the word East in the text field, however the trace outputs this

dyn text =

Can anyone help??

L.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 12:31pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/2 "2002-10-01T12:31:47Z")

</div>

Shouldn’t that read &tr\_1=East?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 12:35pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/3 "2002-10-01T12:35:41Z")

</div>

Also if you’re using MX - why don’t you use loadVars()

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 12:55pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/4 "2002-10-01T12:55:14Z")

</div>

> \*Originally posted by flex \*  
> \*\*Also if you’re using MX - why don’t you use loadVars() \*\*

Neither makes a diference, and I really need to be able trace the value that I am reading in, as until I am sure it is being assign to my var, I cannot do a string compare.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 1:01pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/5 "2002-10-01T13:01:21Z")

</div>

If you’re loading into level 1 - loadVariablesNum("./correctTrains.txt", 1); , try

trace (“dyn text =” + \_level1.tr\_1 );

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 1:11pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/6 "2002-10-01T13:11:36Z")

</div>

> \*Originally posted by flex \*  
> \*\*If you’re loading into level 1 - loadVariablesNum(“./correctTrains.txt”, 1); , try

trace (“dyn text =” + \_level1.tr\_1 ); \*\*

I tried it, no joy ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 1:12pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/7 "2002-10-01T13:12:00Z")

</div>

Try this - the fla has nothing but a dynamic text box with the var set as \_level1.test.

In the first frame I use

loadVariablesNum(“test.txt”, 1);

to load a variable called test from a text file called test.txt.

Make sure the fla and the text file are in the same folder and test the movie - you should see that it displays the loaded variable.

Check your swf and text file are in the same folder.  
Check that you are using \_level1.variable name for the variable.  
And check that all the variables are actually loaded before you call them.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 1:32pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/8 "2002-10-01T13:32:17Z")

</div>

Correction - your swf and text file don’t need to be in the same folder - I meant make sure the path to the text file is correct.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 2:41pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/9 "2002-10-01T14:41:04Z")

</div>

I got it working!

I used an off screen empty movie called dirHolder that contained the following code

onClipEvent(data){  
\_root.dirLoad();  
}

Then in the main actions of the movie (on layer 1) I did the following

stop();  
//loadVariablesNum("./correctTrains.txt", 1);

loadVariables("./correctTrains.txt", \_root.dirHolder);

function dirLoad(){  
//initialize i  
var i=0;  
var count=0;  
dir\_trans1 = dirHolder["\_level1.tr\_1"];  
trace(\_level0.train1\_results + “=” + dir\_trans1);  
if (\_level0.train1\_results == dirHolder["\_level1.tr\_1"]) {  
count++;  
}  
dir\_trans2 = dirHolder["\_level1.tr\_2"];  
trace(\_level0.train2\_results + “=” + dir\_trans2);  
if (\_level0.train2\_results == dirHolder["\_level1.tr\_2"]) {  
count++;  
}  
dir\_trans3 = dirHolder["\_level1.tr\_3"];  
trace(\_level0.train3\_results + “=” + dir\_trans3);  
if (\_level0.train3\_results == dirHolder["\_level1.tr\_3"]) {  
count++;  
}  
dir\_trans4 = dirHolder["\_level1.tr\_4"];  
trace(\_level0.train4\_results + “=” + dir\_trans4);  
if (\_level0.train4\_results == dirHolder["\_level1.tr\_4"]) {  
count++;  
}  
dir\_trans5 = dirHolder["\_level1.tr\_5"];  
trace(\_level0.train5\_results + “=” + dir\_trans5);  
if (\_level0.train5\_results == dirHolder["\_level1.tr\_5"]) {  
count++;  
}  
dir\_trans6 = dirHolder["\_level1.tr\_6"];  
trace(\_level0.train6\_results + “=” + dir\_trans6);  
if (\_level0.train6\_results == dirHolder["\_level1.tr\_6"]) {  
count++;  
}  
dir\_trans7 = dirHolder["\_level1.tr\_7"];  
trace(\_level0.train7\_results + “=” + dir\_trans7);  
if (\_level0.train7\_results == dirHolder["\_level1.tr\_7"]) {  
count++;  
}  
dir\_trans8 = dirHolder["\_level1.tr\_8"];  
trace(\_level0.train8\_results + “=” + dir\_trans8);  
if (\_level0.train8\_results == dirHolder["\_level1.tr\_8"]) {  
count++;  
}  
dir\_trans9 = dirHolder["\_level1.tr\_9"];  
trace(\_level0.train9\_results + “=” + dir\_trans9);  
if (\_level0.train9\_results == dirHolder["\_level1.tr\_9"]) {  
count++;  
}  
dir\_trans10 = dirHolder["\_level1.tr\_10"];  
trace(\_level0.train10\_results + “=” + dir\_trans10);  
if (\_level0.train10\_results == dirHolder["\_level1.tr\_10"]) {  
count++;  
}

```
_level1.score = count;

if (count == 10) {
	_level1.statement = "Excellent";
}
else if (count &gt; 5) {
	_level1.statement = "Not Bad";
}
else {
	_level1.statement = "Very Poor Attempt";
}	

```

}

Got the string comparison going between the Radio Buttons passed (cheers for that Flex) and the value I am loading into the dyn text fields from the data file.

All works with about an hour to spare :).

Thanks for your help gain Flex.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 2:55pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/10 "2002-10-01T14:55:59Z")

</div>

I was going to sugges loading the variables with

mcname.loadVariables();

but I thought there was a reason that you wanted to use loadVarsNum, as the disadvantage of loading to a level is you have to refer to the level. Loading into an mc is the preferred method.

Glad you got it working.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 1, 2002, 9:54pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/11 "2002-10-01T21:54:22Z")

</div>

Just wanted to add that I think the problem was you were calling the variables before they were loaded. With loadVariablesNum you have to manually use code to check if the variables are loaded before you can use them, but with MX you can use the  
onClipEvent (data) which checks to see if the data has been loaded before it’s safe to use it.

EDIT: And the game fla - I did it in request of cybergold, but I get people asking me to help, and then no response so I think I’m going to concentrate on my own projects more - but it wouldn’t be fair to put the fla up because although the coding is mine - the graphics are his. But I am working on another game - for which I put a post in the design forum for a designer - and maybe I’ll put the fla of that on my site. There are already some game fla’s you can download.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 3, 2002, 3:24pm UTC](https://forum.kirupa.com/t/simple-problem-i-hope/6178/12 "2002-10-03T15:24:00Z")

</div>

> \*Originally posted by flex \*  
> \*\*I was going to sugges loading the variables with

mcname.loadVariables();

but I thought there was a reason that you wanted to use loadVarsNum, as the disadvantage of loading to a level is you have to refer to the level. Loading into an mc is the preferred method.

Glad you got it working. \*\*

Thanks for your help 🙂
