PDA

View Full Version : loading external textfile (many variables)


texbala
04-27-2003, 11:43 PM
I am trying to load multiple variables from a single text file...


//dynamic text field has the name as Text
loadVarsText = new loadVars();
loadVarsText.load("graphics_text.txt");
loadVarsText.onLoad = function(success){
if (success){
trace("load done");
Text.html=true;
Text.htmlText = this.graphicsText;
}else{
trace("not loaded");
}
}
btn1.onPress = function(){
Text.htmlText = btn1;
}
btn2.onPress = function(){
Text.htmlText = btn2;
}
/*
Text file format as:
&graphicsText
&btn1=This is a sample Text
&btn2=This is a 2 sample Text
*/


I have done this earlier, but doesnt' seem to work now :confused: :confused: (i know there is something wrong in the text file format)..

annexion
04-28-2003, 12:47 AM
Try quotation marks around the variable values in the text file.

&variable="string"

texbala
04-28-2003, 12:51 AM
it didn't work :(

&graphicsText
&btn1="This is a sample Text"
&btn2="This is a 2 sample Text"

Ricod
04-28-2003, 01:11 AM
Does the trace return "load done" or "not loaded" ?

Also, don't you have to assign a value to graphicsText ?

texbala
04-28-2003, 01:15 AM
the text is loaded - "load done" in out put window

attached is the sample file..

not sure what you mean by
assign a value to graphicsText??

EsChEr
04-28-2003, 02:02 AM
try this, hope it helpsloadVarsText = new loadVars();
loadVarsText.load("graphics_text.txt");
loadVarsText.onLoad = function(success) {
if (success) {
trace("load done");
Text.html = true;
Text.htmlText = this.graphicsText;
btn1.onPress = function() {
Text.htmlText = this.btn1;
};
btn2.onPress = function() {
Text.htmlText = this.btn2;
};
} else {
trace("not loaded");
}
};
/*
Text file format as:
&graphicsText=there must be something here
&btn1=This is a sample Text
&btn2=This is a 2 sample Text
*/
mind my modification to the txt

texbala
04-28-2003, 02:08 AM
still not working??

EsChEr
04-28-2003, 02:15 AM
loadVarsText = new loadVars();
loadVarsText.load("graphics_text.txt");
loadVarsText.onLoad = function(success) {
if (success) {
trace("load done");
Text.html = true;
Text.htmlText = this.graphicsText;
btn1.onPress = function() {
Text.htmlText = loadVarsText.btn1;
};
btn2.onPress = function() {
Text.htmlText = loadVarsText.btn2;
};
} else {
trace("not loaded");
}
};

texbala
04-28-2003, 02:24 AM
thnx EsChEr...

it worked... i was struggling for almost 30 mins and left it :(

thnx again!!

EsChEr
04-28-2003, 02:26 AM
np
glad i could help

Vasudevan
06-14-2010, 06:20 PM
I want to know how to include & in my dynamic text as the company name for which my website template is done is "S & S Foundations" as & is the delimiter is there a way to include & in my text too