PDA

View Full Version : help me modify AS



Neo-Geo
August 2nd, 2003, 11:19 AM
i used this AS to load external text (load on its own)

loadTexts = new loadVars();
loadTexts.load("speaknote.txt");
loadTexts.onLoad = function() {
textBox.text = this.speaknote;
};


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

i try to change it to this


loadTexts = new loadVars();
loadTexts.load("speaknote.txt");
buttonToLoad.onPress = function() {
textBox.text = this.speaknote;
};


whats wrong with this AS, why it wont work?

claudio
August 2nd, 2003, 11:29 AM
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;

Neo-Geo
August 2nd, 2003, 11:52 AM
claudio,
it load before i can press the button

claudio
August 2nd, 2003, 11:58 AM
Weird... It should work. :-\

Neo-Geo
August 2nd, 2003, 12:09 PM
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?

claudio
August 2nd, 2003, 12:17 PM
Nope because im only calling the function on button press.
Check my attached file

Neo-Geo
August 2nd, 2003, 12:58 PM
thanks for your help. its ok now

claudio
August 2nd, 2003, 01:03 PM
:thumb: