# LoadVariablesNum (Flash MX)

**URL:** <https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915>\
**Category:** Uncategorized\
**Created:** [July 8, 2004, 7:11pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915 "2004-07-08T19:11:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SnailMan](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@SnailMan](https://forum.kirupa.com/u/SnailMan)\
**Post date:** [July 8, 2004, 7:11pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/1 "2004-07-08T19:11:48Z")

</div>

Hi all,

I’m making a game and I need to load variables into my flash movie from a database. I’m using asp and i know it works fine becuase it outputs what I want.

My problem is that when I try to load the data into flash, it won’t let me use the variables. If I put a dynamic textfield on the stage with fname (one of my variables), the text field diplays the correct data, but when I say trace(fname) with having the text field, “undefined” pops up.

How can I solve this?

- Ian

---

<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:** [July 8, 2004, 7:34pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/2 "2004-07-08T19:34:32Z")

</div>

```auto

trace(fname.text);

```

🙂

---

<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:** [July 8, 2004, 8:19pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/3 "2004-07-08T20:19:51Z")

</div>

Thanks for the reply, but that is not working. I’ll give a bit more information:

It’s a Mr. Potato Head and this is for the function that lets people view heads from a database that other people have submitted. You can see it at [http://www.snailgames.tk/games/potatohead](http://www.snailgames.tk/games/potatohead).

The ASP file outputs in this format: tname=Ian&tpname=eye2|mouth4|nose3&tpx=172|169|160&tpy=143|297|215&tpxscale=100|100|100&tpyscale=100|100|100&tprotation=0|0|0

This is the Action Script in the main timeline so far:

[INDENT]stop();

loadVariablesNum(“viewHead.txt”, 0);

for (i = 1; i \<= CountParseString(vpartname, “|”); i++) {  
\_root.attachMovie(ParseString(tpname, “|”, i), “part” + i, i);  
\_root[“part” + i].\_x = ParseString(tpx, “|”, i);  
\_root[“part” + i].\_y = ParseString(tpy, “|”, i);  
\_root[“part” + i].\_xscale = ParseString(tpxscale, “|”, i);  
\_root[“part” + i].\_yscale = ParseString(tpyscale, “|”, i);  
\_root[“part” + i].\_rotation = ParseString(tprotation, “|”, i);  
}

function CountParseString(str, char) {  
temp = 1;  
for (f = 0; f \<= str.length; f ++) {  
if (str.charAt(f) == char) {  
temp ++;  
}  
}  
return(temp);  
}  
function ParseString(str, char, section) {  
temp = 1;  
str = str + “|”;  
for (f = 0; f \<= str.length; f ++) {  
if (temp == section) {  
temp = “”;  
for (g = f; g \<= str.length; g++) {  
if (str.charAt(g) != char) {  
temp += str.charAt(g);  
} else {  
return(temp);  
}  
}  
}  
if (str.charAt(f) == char) {  
temp ++;  
}  
}  
}[/INDENT]

In that for loop, it takes the variables it is _supposed_ to be getting, and uses them to attach the face features and give them \_x, \_y etc. CountParseString is a function that returns the sections in str separated by char. ParseString is a function that returns the value of section in str separated by char.

I hope this helps.

---

<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:** [July 8, 2004, 11:16pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/4 "2004-07-08T23:16:32Z")

</div>

I found a thread on this that solved my problem: [http://www.kirupaforum.com/forums/showthread.php?t=31032](http://www.kirupaforum.com/forums/showthread.php?t=31032)

I changed:

loadVariablesNum(“viewHead.txt”, 0);

for (i = 1; i \<= CountParseString(vpartname, “|”); i++) {  
\_root.attachMovie(ParseString(tpname, “|”, i), “part” + i, i);  
\_root[“part” + i].\_x = ParseString(tpx, “|”, i);  
\_root[“part” + i].\_y = ParseString(tpy, “|”, i);  
\_root[“part” + i].\_xscale = ParseString(tpxscale, “|”, i);  
\_root[“part” + i].\_yscale = ParseString(tpyscale, “|”, i);  
\_root[“part” + i].\_rotation = ParseString(tprotation, “|”, i);  
}

to:

lv = new LoadVars()  
lv.onLoad = function(success) {  
if(success) {  
for (i = 1; i \<= CountParseString(this.tpname, “|”); i++) {  
\_root.attachMovie(ParseString(this.tpname, “|”, i), “part” + i, i);  
\_root[“part” + i].\_x = ParseString(this.tpx, “|”, i);  
\_root[“part” + i].\_y = ParseString(this.tpy, “|”, i);  
\_root[“part” + i].\_xscale = ParseString(this.tpxscale, “|”, i);  
\_root[“part” + i].\_yscale = ParseString(this.tpyscale, “|”, i);  
\_root[“part” + i].\_rotation = ParseString(this.tprotation, “|”, i);  
partnumber = i;  
}  
}  
}  
lv.load(“viewHead.txt”)

---

<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:** [July 8, 2004, 11:27pm UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/5 "2004-07-08T23:27:14Z")

</div>

Yeah I stopped using loadVariablesNum.

You should read this tutorial [http://www.flash-db.com/Tutorials/loading/loadingData.php?page=1](http://www.flash-db.com/Tutorials/loading/loadingData.php?page=1)

It’s real good and gets into a lot fo detail on how it works with both ASP/PHP.

---

<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:** [July 9, 2004, 1:55am UTC](https://forum.kirupa.com/t/loadvariablesnum-flash-mx/56915/6 "2004-07-09T01:55:38Z")

</div>

I finished the game!

If anyone wants to see it, you can find it at [http://www.snailgames.tk/games/potatohead](http://www.snailgames.tk/games/potatohead)
