I have created a news ticker and I would like to load dynamic text into it. The ticker flows from right to left and works on a continuous loop. How do I load the dynamic text?
you can use the following code to load from text file
[AS]
loadText = new loadVars();
loadText.load(“filename.txt”);
loadText.onLoad = function() {
statement.text = this.message;
};
[/AS]
the file should be in the same folder as the swf file or you must use relative addressing to load it.
you text file must begin with:
message = blablabla…
statement is the instance name of your text field
or if you want to load text directly from flash you can simply put
statement.text = “the text you want here”
hello, i’m new to flash.
i need help regarding problems of displaying different text in a single dynamic text box. You see, i am able to make it work using kirupa’s tutorial, but how do i write a actionscript for a button to display another text in the same text box? I been using the command:
scroller.text = this.maintext2;
but it gives me nothing in place of the former text. I’m rather puzzled by this. And also i wrote the maintext.txt with the the following :
maintext1 = blah blah blah …
&maintext2 = blah blah blah …
is it gonna work with my problematic method? Your kind advice pls, thanks.
I think you spoke too soon
Kirupa recently added up a tutorial on this exact thing…
cool, that was a another superb tutorial
but it seems that there were 1 different text file for each text, is it possible to have them together separated by (&) and displayed properly?
Of course…
[AS]loadText = new loadVars();
loadText.load(“text1.txt”);
loadText.onLoad = function(success) {
if (success) {
newsBox.html = true;
newsBox.htmlText = this.myNews1;
}
};[/AS]
Put that on a frame
This in the textfile…
myNews1=This is Text one
&myNews2=This is Text Two
&myNews3=This is Text Three
And this on the buttons…
[AS]on (release) {
newsBox.htmlText = loadtext.myNews1;
}[/AS]
(of course you change myNews1 to the correct variable name)
it works, thanks almighty !
So glad now its possible, or else i’m forever stuck here!
Also you can clear out the textbox (so the scrollbar resets back at the top) by adding that into an on(press)…
[AS]on (press) {
newsBox.htmlText = “”;
}
on (release) {
newsBox.htmlText = loadtext.myNews1;
}[/AS]
Im sure theres an easier (more efficient) way to do this, but right now Im in a rush and I can’t think of one.
Gotta go. Later.
Lostinbeta, yea i think u can achieve the same effect with this code:
[AS]
on (release) {
newsBox.scroll = 0; //resets scrollbar position to 0
newsBox.htmlText = loadtext.myNews1;
}
[/AS]