ok how to i make a button so when i press it, it loads an external .txt files in my text box in flash
There are tutes about text loadings here
were can you post one please
here’s the link :):
http://www.kirupaforum.com/forums/search.php?s=
I’m kind of still new at this myself but I’m pretty sure all you have to do is put a name for the variable (Var:) in the dynamic text properties box (NOT the instance name), for example: textField
Then on your button you say something like:
on (release){
loadVariables(“external_text.txt”, textField);}
This says to load the text file called “external_text” into the dynamic text box you created that you called “textField”.
Hope this helps!
i tested that but it did not work
am i doing it wrong
upload your .fla file… then we can check to see if you have everything correct
i’m not the original poster but i can’t get lunatic’s script to work either…
.zip attached
on another note, while searching for an answer i read, io have no idea whether it’s relevant:
http://www.macromedia.com/support/flash/ts/documents/dynamic_text_scrollmx.htm
“Loading text into a dynamic text field in Flash MX is done differently. In Flash MX text is it’s own ActionScript object, so a text field can have both a variable name and an instance name (see Flash MX Text fields have instance names and variable names, TechNote 16184, for details). Flash MX also introduces a more sophisticated action for loading external data called loadVars(). These two methods are combined to load external text to a scrolling text field created using the ScrollBar component.”
on (release) {
loadText = new loadVars();
loadText.load(“kirupa.txt”);
loadText.onLoad = function() {
_root.textField = loadText;
};
}
this seems to work…
anyone any tips how how to get text not show up with %20 as spaces? i tried unicode and a several other formats…
meisje
_root.textField = unescape(loadText);
thanks kax :toad:
you’re welcome.
one more issue, a loaded text is always trailed by the following:
=&onLoad=[type Function]
(major thunderstorm is coming turning of puter for the while)
if you’re still using the same script you posted above, try adding this line of code:
ASSetPropFlags(loadText, "onLoad", 1);
however, i encourage you to follow the tutorial here at kirupa.com
http://www.kirupa.com/developer/mx/dynamic_scroller.htm
thanks for the encouragement kax i have done the tutorial now, please correct me if i’m wrong:
scene: button and dynamic textfield.
name the textfield “textField” in the instance name box (this time NOT the var name!!).
on the button hang this script:
on (release) {
loadText = new loadVars();
loadText.load(“kirupa.txt”);
loadText.onLoad = function() {
textField.text = this.kirupatext;
};
}
then make a textfile and put:
kirupatext=
followed directly by the rest of your text.
save the file as:
kirupa.txt
for loading other text just copy the code and only change “kirupa.txt” to whatever you want loaded
voilá kirupá thanks again kax
no problem, meisje. =)
by the way, i think you should read this technote. i’m telling you this because of the instance name you used for the TextField.
http://www.macromedia.com/support/flash/ts/documents/naming_strategies.htm
information assimilated :thumb:
and this one is for you :flower: later kax!
see ya!
I`m trying to use the code creating a function called “loadNote” but the text is not loading
// define the function loadNote
function loadNote (idnote) {
_root.attachnote.attachMovie("mcnote", "mcnote", 1);
_root.attachnote.posY = 300;
loadText = new LoadVars();
loadText.load(idnote);
loadText.onLoad = function () {
_root.attachnote.mcnote.loadtxt = loadText;
trace = "function loadNote ok";
}
}
on my btn01 action I wrote:
on(release) {
// call the function loadNote on stage
_root.loadNote("cap02/notes/note" + "01" + ".txt");
}
The attach action is ok but the text is not loading inside mcnote, in textfield “loadtxt”.
Can some help me?
Thanks