Help me modify AS

i used this AS to load external text (load on its own)
[AS]
loadTexts = new loadVars();
loadTexts.load(“speaknote.txt”);
loadTexts.onLoad = function() {
textBox.text = this.speaknote;
};
[/AS]

how can i modify this AS so that it will load when i press a button

i try to change it to this

[AS]
loadTexts = new loadVars();
loadTexts.load(“speaknote.txt”);
buttonToLoad.onPress = function() {
textBox.text = this.speaknote;
};
[/AS]

whats wrong with this AS, why it wont work?

[AS]function loadText() {
loadTexts = new loadVars();
loadTexts.load(“speaknote.txt”);
loadTexts.onLoad = function(success) {
if (success) {
textBox.text = this.speaknote;
} else {
textBox.text = “Error loading data”;
}
};
}
buttonToLoad.onPress = loadText;[/AS]

claudio,
it load before i can press the button

Weird… It should work. :-\

loadTexts.onLoad = function(success) {
if (success) {
textBox.text = this.speaknote;

doesnt this part show that if the frame is load
the the text will appear?

Nope because im only calling the function on button press.
Check my attached file

thanks for your help. its ok now

:thumb: