Grupos » Flash Maniacs » Temas » [T] Dynamically Load Text

Listado 1-15 de 22    1   2   de  2 Siguiente >
Autor Mensaje
Flash Mod

M/22
,
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder a esta publicación Publicado:  may 6, 2007 8:56 p.m.
Coming in just a moment...
Flash Mod


M/22
,
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: may 6, 2007 9:06 p.m.
This tutorial will discuss how to load text dynamically through a text file with out the use of xml or css.

First, create a Dynamic text field and give it an instance name.
Then give the text all of the properties for font family and <myspace>size</myspace> that you want for it. Make sure the "Render text as HTML" button is selected in the text panel.
If you are planning on having some of your text bolded then be sure to select bold for the font. Don't worry, all your text won't appear in bold.

For this example I have created two different text fields to demonstrate how to load multiple text fields.
test1_txt
text2_txt

Now open notepad or any text editing program and create a new document_
The way to create a variable that flash can read is &variableName=

In my text file, I create two sets of data and named them text1 and text2.

Here is my text.
&text1=This <font color="#FFFFFF">text</font> <u>is</u> <font <myspace>size</myspace>="12">dynamically</font> loaded through an external text file&text2=So <b>is this</b> text

All your text must be on one line. When entering text, never hit the Return button, to make a line break use <br>.
save the file as test.txt. Be sure to save it as a .txt file not a .doc or any other format.

In a new layer, hit F9 to enter your actions panel.

ActionScript

var myText:LoadVars = new LoadVars ();
myText.load("test.txt");

myText.onLoad = function(success) {
if(success){
test1_txt.htmlText = myText.text1;
test2_txt.htmlText = myText.text2;
}
}


var myText:LoadVars = new LoadVars ();
myText.load("test.txt");


First we have to create a variable and give it a name. I named it myText. Then strict type it to LoadVars
Then we create a new LoadVars object to store all the data in. And we are telling Flash to load the data from the test.txt file.



myText.onLoad = function(success) {
if(success){
}
}


Next we are telling Flash to when it loads, it needs to perform a function. If this loading function is successful then we want to do everything inside the brackets.



test1_txt.htmlText = myText.text1;
test2_txt.htmlText = myText.text2;


This says that the text property of test1_txt and text2_txt will be displayed as HTML and it will be equal to the loaded data from your myText variable.

dynamicText.zip

Thank you for reading this tutorial. I hope you find it very helpful with your flash animations. For any help with this tutorial or questions, please post only in this forum thread.

~Flash Mods
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: may 7, 2007 2:57 a.m.
Your welcome :)
╔╪╧╩╦çëþħκļöκ╧╦╬╩╕


M/37
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: may 7, 2007 3:11 a.m.
that is awesome, thanks ^_^
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: may 13, 2007 5:05 a.m.
I have had this issue with MANY different things. If you want to call actions of a movie clip or text or whatever inside another movie clip from the main time line then the movie clip or text you are trying to target must be in the first frame. Not sure why that is, just flash can't find it unless it is in the first frame. So what you have to do is put the code in the time line of the movie clip instead. Thats the only way I have ever found to get around it.
The Great Monkey Boy


M/21
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 8, 2007 4:23 p.m.
When loading the text file inside the movie clip when it on myspace....where can i stick the text file.

do i need to host it on the web and if so is there any website cheap as possible (free would be better) to do this.

thanx in advance you guys

Regards

Ashley (The Great Monkey Boy)
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 8, 2007 4:24 p.m.
yea, you have to host it on the internet and use the full URL for it.

try fileden.com
The Great Monkey Boy


M/21
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 8, 2007 4:46 p.m.
that help loads thanx.

quick question though where would i put the html link for the text in the action scrip?

thank you again
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 8, 2007 4:48 p.m.
The Great Monkey Boy wrote:
that help loads thanx.

quick question though where would i put the html link for the text in the action scrip?

thank you again


var myText:LoadVars = new LoadVars ();
myText.load("URL TO TEXT FILE");
The Great Monkey Boy


M/21
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 9, 2007 12:14 a.m.
sorry about this but im still having a little trouble....i know that this may be irritating you all now and im sorry i really am.

i have written all the action script needed but when i view it in the web browser (firefox and IE) it comes up with a message saying:-

<center></center>



i don't know whats going wrong and i hope that you guys can help...im sorry for being such a noobe.

im a 3d animator and flash has never been my strongest point lol

i hope you can help
Ryan


M/22
Denver,
Colorado
Mensaje instantáneo
Enviar mensaje
Responde con esta cita Responder Publicado: jul 9, 2007 12:19 a.m.
so click setting and then allow flash player to access the internet, thats all its trying to do.
Listado 1-15 de 22    1   2   de  2 Siguiente >

dspPostReplies v29