0
Dynamic Text with external .txt files
Explorer
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/td-p/86647
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
I need help getting dynamic text to display. I've used the
following tutorials (among others).
http://www.kirupa.com/developer/mx/dynamic_scroller.htm
http://www.kirupa.com/developer/mx/multiple_dynamictext.htm
In Flash 8 on last frame of maintimeline of movie, I have a layer with a background image, 2 buttons and a dynamic textbox (made scrollable) with scrollbar component. Textbox is given a var of "content", and an instance name of "textBox", which is referenced in scrollbar parameters.
I have created 3 text .txt files, and saved them to same folder with movie .swf file. Text in files is preceeded by "content=" on line preceeding text to correspond with var of dynamic textbox. The files were created in Rich text format on Mac OSX4.11 and saved with .rtf extension, then file extension was changed to .txt (wouldn't save as .txt)
I've added the following actionscript to this last frame:
loadText = new LoadVars();
loadText.load("TEXTintro.txt");
//creating the loadVarsText function
loadText.onLoad = function(success){
if (success){
textBox.text = this.content;
}
else{
trace("Error loading external content");
}
}
Buttons have an instance name assigned with the following actionscript:
on (release) {
loadText = new LoadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function(success){
if (success){
textBox.text = this.content;
}
else{
trace("Error loading external content");
}
}
When I test movie, I can see buttons on last frame of movie, but they don't load any text when pressed, and "undefined" text appears in upper left corner of text box before I press either button.
I am getting the following Output errors:
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 1: Statement block must be terminated by '}'
on (release) {
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 11: Syntax error.
}
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 1: Statement block must be terminated by '}'
on (release) {
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 11: Syntax error.
}
Total ActionScript Errors: 4 Reported Errors: 4
http://www.kirupa.com/developer/mx/dynamic_scroller.htm
http://www.kirupa.com/developer/mx/multiple_dynamictext.htm
In Flash 8 on last frame of maintimeline of movie, I have a layer with a background image, 2 buttons and a dynamic textbox (made scrollable) with scrollbar component. Textbox is given a var of "content", and an instance name of "textBox", which is referenced in scrollbar parameters.
I have created 3 text .txt files, and saved them to same folder with movie .swf file. Text in files is preceeded by "content=" on line preceeding text to correspond with var of dynamic textbox. The files were created in Rich text format on Mac OSX4.11 and saved with .rtf extension, then file extension was changed to .txt (wouldn't save as .txt)
I've added the following actionscript to this last frame:
loadText = new LoadVars();
loadText.load("TEXTintro.txt");
//creating the loadVarsText function
loadText.onLoad = function(success){
if (success){
textBox.text = this.content;
}
else{
trace("Error loading external content");
}
}
Buttons have an instance name assigned with the following actionscript:
on (release) {
loadText = new LoadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function(success){
if (success){
textBox.text = this.content;
}
else{
trace("Error loading external content");
}
}
When I test movie, I can see buttons on last frame of movie, but they don't load any text when pressed, and "undefined" text appears in upper left corner of text box before I press either button.
I am getting the following Output errors:
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 1: Statement block must be terminated by '}'
on (release) {
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 11: Syntax error.
}
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 1: Statement block must be terminated by '}'
on (release) {
**Error** Scene=MoonOfWintertime, layer=TextBox, frame=2500:Line 11: Syntax error.
}
Total ActionScript Errors: 4 Reported Errors: 4
TOPICS
ActionScript
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86648#M241958
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
I haven't taken time to review the details of the code except
to see that the error messages are probably accurate... as far as I
can see there are 4 "{" but only 3 "}" for your button code.
Also, you probably need to declare the content variable (var content;) in the code outside any functions. Defining it for/on the textfield alone doesn't normally fly (for me).
I'm not sure about the impact of using a disguised rtf file. Don't Macs come with a simple ascii text editor? With all the condemning TV ads about PC's, I'd think they'd have that covered.
Also, you probably need to declare the content variable (var content;) in the code outside any functions. Defining it for/on the textfield alone doesn't normally fly (for me).
I'm not sure about the impact of using a disguised rtf file. Don't Macs come with a simple ascii text editor? With all the condemning TV ads about PC's, I'd think they'd have that covered.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
dstx
AUTHOR
Explorer
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86649#M241959
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
What should I check or change based upon error Output?
I don't know enough to understand what errors are indicating.
Also, how do I "declare the content variable (var content;) in the code outside any functions" as you suggest?
I don't know enough to understand what errors are indicating.
Also, how do I "declare the content variable (var content;) in the code outside any functions" as you suggest?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86650#M241960
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
Add another "}" to the end of your buttons' code
var content;
loadText = new LoadVars();
...etc
var content;
loadText = new LoadVars();
...etc
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
dstx
AUTHOR
Explorer
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86651#M241961
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
No more output errors, buttons still not working, but I got
my intro .txt file to load in textbox that loads with frame using
the following code I tried from another tutorial:
loadText = new LoadVars();
loadText.onLoad = function() {
textBox.html=true;
textBox.htmlText = this.textContent;
};
loadText.load("TEXTintro.txt");
Tried the following code with buttons, but doesn't work. Other code suggestions?
on (release) {
loadText = new LoadVars();
loadText.onLoad = function() {
};
loadText.load("TEXT2.txt");
}
on (release) {
loadText = new LoadVars();
loadText.onLoad = function() {
textBox.html=true;
textBox.htmlText = this.textContent;
};
loadText.load("TEXT1.txt");
}
loadText = new LoadVars();
loadText.onLoad = function() {
textBox.html=true;
textBox.htmlText = this.textContent;
};
loadText.load("TEXTintro.txt");
Tried the following code with buttons, but doesn't work. Other code suggestions?
on (release) {
loadText = new LoadVars();
loadText.onLoad = function() {
};
loadText.load("TEXT2.txt");
}
on (release) {
loadText = new LoadVars();
loadText.onLoad = function() {
textBox.html=true;
textBox.htmlText = this.textContent;
};
loadText.load("TEXT1.txt");
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
dstx
AUTHOR
Explorer
,
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86652#M241962
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
Just got button to work using the following:
on (release) {
loadText = new LoadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function() {
textBox.text = this.textContent;
};
}
Can anyone tell me how to style text in dynamic textbox?
Right now, all I can get is the font type, size and color as set in the textbox properties window.
Is it possible to attach or embed a CSS stylesheet?
And use html in external txt file for more control of text display?
If this can be done, how do you do it?
on (release) {
loadText = new LoadVars();
loadText.load("TEXT1.txt");
loadText.onLoad = function() {
textBox.text = this.textContent;
};
}
Can anyone tell me how to style text in dynamic textbox?
Right now, all I can get is the font type, size and color as set in the textbox properties window.
Is it possible to attach or embed a CSS stylesheet?
And use html in external txt file for more control of text display?
If this can be done, how do you do it?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
dstx
AUTHOR
Explorer
,
LATEST
/t5/animate-discussions/dynamic-text-with-external-txt-files/m-p/86653#M241963
Jan 02, 2009
Jan 02, 2009
Copy link to clipboard
Copied
BTW the code above only works on new button I draw with
toolbar and convert to button symbol.
How can I get code to work with button component I select from Components window?
How can I get code to work with button component I select from Components window?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

