Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : I still don't understand how to load text in an MC!


OverRatedMedia
5/23/2005 12:00:00 AM
hey.
first, make the text field. there are two ways to do this(that I know of):draw
it, or create it dynamically through action script. what ever you do, if you
draw it, do not change its size through the proporties panel:this streches the
text. Make it about the size you want, as close as possible, and then make it
exact through the proporties panel. you can also change its proporties through
action script, look up the text field class and text format class. Give the
text field an instance name.
Next, make a new xml variable. This will hold the text.
Decide whether or not the text will be html text or not(this includes html,
php, asp).
Next, load them text into the xml variable. You can load any type of
file(almost):txt, html, xml, php, asp.
Next, format
Next, onLoad load the text into the textfield.
Format the text field the way you want either manually or through action
script(recommended).
so, here is what the action script should look like(you can modify it
somewhat):
var my_xml = new XML();
my_xml.load("fileURL");
my_txt.html = true/false;
my_xml.onLoad = function () {
my_txt.htmlText = my_xml;
}
this should about cover it. if you have any questions, let me know... I hope
that helped!

(_seb_)
5/23/2005 7:17:56 PM
I have not yet managed to understand how to load external text in an MC.
I have done it several times successfully by copying and pasting some
scripts found here and there, and by trial and error, I got the scripts
to work.

But the more I look in my Flash MX Bible or at these scripts I've used,
the less I understand how it works.
I don't understand why I have to create variables, or an onLoad
function, or if I could just do something very simple.

something like:


myMC.text = load("textFolder/mytext.txt");

I don't see why it should be more complicated, and if it really has to,
please explain why

--
(_seb_)
5/23/2005 11:04:32 PM
thanks, that works.
I am surprised that so many steps are necessary to do such a simple
thing, though.

Why couldn't Macromedia implement something like:

mytextField.loadText("mytext.txt");

as in:

myMC.loadMovie("myMovie.jpg");

just wondering


[quoted text, click to view]

--
AddThis Social Bookmark Button