PDA

View Full Version : text var in textArea


sconer
01-15-2007, 02:47 AM
I am loading an external txt into my flash. However in order to set my text, to be the text from the txt, the Var under the text settings must be equal to what the variable is in the txt. Instead of using text tool I am using a textArea. how do I set the variable of this so it may work?

inhan
01-15-2007, 02:57 AM
textArea.variable = "something";

Is it what you're asking? Or do you wanna use some variable obtained from a text, that is loaded in a text field?

sconer
01-15-2007, 03:00 AM
i've done that. no success.

inhan
01-15-2007, 03:02 AM
What exactly is it that you're trying to do?

By the way if you're trying to give variable to a text field, and if
myTF.myVariable = "myText";
doesn't work, then prior, try to add:
var myText:TextField = new TextField;

sconer
01-15-2007, 03:06 AM
chat_Box.variable = "disp";
loadVariablesNum("talk.txt", 0);

load text from a txt document into my textArea.
if I replace the textArea with a text box, and make the Var in that disp. then it will work. but I need to figure out how to do it with a textArea.

my txt document contains: disp=hello

inhan
01-15-2007, 03:21 AM
A bit changed version of what I had posted in another forum:

this.createTextField("myTextField", 1, 52, 168, 413, 169);
myTextField.variable = "theText";
var myLV:LoadVars = new LoadVars();
myLV.onData = function(src:String):Void {
if (src != undefined) {
theText = src;
} else {
theText = "Unable to load external file.";
}
};
myLV.load("myText.txt");
creates the text filed named "myTextField", gives it a variable called "theText", and sets its value to "myText.txt".

By the way loadMovieNum lets you load data into levels, and 0 is the main swf you have.

sconer
01-15-2007, 03:23 AM
very cool thx i will try this.

inhan
01-15-2007, 03:25 AM
No problem.

sconer
01-15-2007, 03:55 AM
lol ok so i got it to work now. only the textarea is invisible. maybe something is wrong with my depth b/c i don't know what that is.

BernzSed
01-15-2007, 04:45 AM
Are you using a TextField or are you using the TextArea component? There's a difference; TextArea doesn't have the "variable" property.
To set the text of a TextArea, you need to set the value of TextArea.text

So, your code would be something like

var myLV:LoadVars = new LoadVars();
myLV.onData = function(src:String):Void {
if (src != undefined) {
myTextArea.text = src;
} else {
myTextArea.text = "Unable to load external file.";
}
};
myLV.load("myText.txt");
where myTextArea is the name of the TextArea.

Also, using that method, you wouldn't have to put "disp=" in the txt file.

sconer
01-15-2007, 07:06 AM
thank you so much i was really confused.

inhan
01-15-2007, 09:20 PM
Either send you file or the code and we'll sort it out.