PDA

View Full Version : Displaying Data from an External File by pressing a button



SC5
January 10th, 2005, 07:24 PM
Alright guys, I'm almost done with my site http://www.flashkit.com/board/images/smilies/smile.gif just one last actionscript stub. I'm loading text from an external file (a notepad). Now all I want is to be able to change the text by loading text from another external file when a certain button is pressed. Basically, I got this as my default text which loads automatically at the start:

loadText = new LoadVars();
loadText.load("data.txt");
loadText.onLoad = function() {
title.text = this.title;
info.text = this.info;
body.text = this.body;

};

but now I want to load text from a different file (data2.txt) by the press of a button. I also have a transition animation so work with me. It would be...

b3.onRelease = function() {
if (_root.section != "photos.swf") {
//I also got this pic (swf) that changes on the button release//
_root.section = "photos.swf";
_root.transition.gotoAndPlay("closing");

so what exactly do I add to be able to change the text source?

scotty
January 11th, 2005, 12:02 PM
function loadTxtFile(file){
loadText = new LoadVars();
loadText.load(file);
loadText.onLoad = function() {
title.text = this.title;
info.text = this.info;
body.text = this.body;
}
};
//to load the first one
loadxtFile("data.txt");
//to load a different one with a button
yourButton.onRelease = function(){
loadxtFile("data2.txt");
}

scotty(-: