[FMX] Loading External Data, this is keeping me up at night

Hi,

In the following example can you explain why loading the text with button event handler is treated like HTML.

http://www.kirupa.com/developer/mx/externaldata.htm

http://www.kirupa.com/developer/mx/multiple_dynamictext.htm

And in the latter tutorial the text is treated like a variable, which I understand. Is it possilbe to alter the fomer tutorial to load the data as a variable and not HTML?

                            *

I dont understand, those tutorials use the same method.

Hi,

Thanks for your prompt relpy. In the tutorial written by Kirupa he loads the text as a variable.

loadText = new loadVars();
loadText.load(“data.txt”);
loadText.onLoad = function() {
name.text = this.name;
email.text = this.email;
location.text = this.location;
};
In this example the data is loaded as HTML, but does not contain HTML formatting.
on (release) {
loadText = new loadVars();
loadText.load(“TEXT1.txt”);
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}

I’m just wondering if this the best practice for using the data with button events, or is there a method to use kiupa’s method with the button events?

You can use:

on (release) {loadText = new loadVars();
loadText.load("data.txt");
loadText.onLoad = function() {
name.text = this.name;
email.text = this.email;
location.text = this.location;
};
};

Thanks again,
I was wondering how to modify the second code example to omit the HTML formatting call. However if this is the best code to use, I’ll simply get some sleep.
on (release) {
loadText = new loadVars();
loadText.load(“TEXT1.txt”);
loadText.onLoad = function(success) {
if (success) {
// trace(success);
newsBox.html = true;
newsBox.htmlText = this.myNews;
}
};
}

Forget about the [font=Courier New]textfield.html[/font] property and use the [font=Courier New]textfield.text[/font] property to assign the variable in the textfile to the textfield:

newsBox.text = this.myNews;