-
Actionscript problem
I have a script that loads variables from a text file into two dynamic text fields . It works and the values display in the dynamic text boxes on screen.
My difficulty comes when I try and find the length of the value in the dynamic text field. It is the same no matter what the length of the string is and the value is 20 both times.
The text file:
&word1=This is a string&
&word2=This is a second String&
Actionscript
loadVariables("text.txt","");
myVar1 = _root.word1;
trace (myVar1.length);
myVar2 = _root.word2;
trace (myVar2.length);
The names of the dynamic instances are text1 and text2. The name of the dynamic variables is word1 and word2
What am I doing wrong?
-
.
Hi,
Maybe try using loadVars in stead as you know when and if the file has loaded correctly.
PHP Code:
var getVars:LoadVars = new LoadVars(); getVars.load("text.txt",_root); getVars.onLoad = function(success) { if (success) { var myVar1 = this.word1; text1.text = myVar1; trace(myVar1.length); var myVar2 = this.word2; text2.text = myVar2; trace(myVar2.length); } };
Or if you wish to continue using loadVariables or loadVariablesNum, take a look here, http://www.actionscript.org/resource...cts/Page1.html
-
That's brilliant. Thank you! It works perfectly!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|