Using basic html tags in dynamically loaded text

ok this is probably so basic but - how do i make say <b> tags in a notepad file load properly in my swf.

It seems to work when I “reload” a text field with different text - but not when it first loads.

My rudimentary code reads

  loadText = new LoadVars();
loadText.load("journal2.txt");
loadText.onLoad = function() {
 wordspre.text = this.wordspre;

thanks in advance

Hi

I know the .text property works sometimes,or often, or most of the time; but for consitantcy sake I would try .htmlText as the property to load html formatted text into. While html formatted text does work in a text box (set for html) loaded into the .text property, it may be the cause of it not working the first time in this case. Maybe something about it realizing its html and is good to go after on next load.
Otherwise, I’d switch loaded files to test if the second one which loads properly will load in first position; It may just be your data.

Hope this helps

Findal
www.fndzinz.com

ok tried that - it just made everything formatted with html tags dissapear!

loadText = new LoadVars();
loadText.load("journal2.txt");
loadText.onLoad = function(success) {
    if (success) {
        wordspre.html = true;
        wordspre.htmlText = this.newsText;
    }
};  

Change the newsText part of the code to your variable name in the text file. Should work.

hmmm ok - still happening - that is all text not wrapped in <b> tags is appearing fine - where as all text wrapped in <b> tags is not appearing

Hmmm, this is curious.
The load vars seems fine,

loadText = new LoadVars();
loadText.load(“journal2.txt”);
loadText.onLoad = function(success) {
if (success) {
wordspre.html = true;
wordspre.htmlText = loadText.newsText;
}
};

So, it must either be the data file or the textbox. It IS a textbox and not something else like an area or other component?
Could you post the sample(part) of data you are trying to load? Just in case your <b> tags don’t have a format like: <p><b>Text Here</b></p> which would make a difference.

When you said that my previous idea didn’t work, " it just made everything formatted with html tags dissapear!" ; Which did you mean? switching data files made it dissapear? That points to the data being wrong format in my mind, if it worked with one file but not the other.

Double check the textfield is set to html text also if it is not created dynamically . :slight_smile:
EDIT:
ALSO, make sure you have embedded the BOLD version of the font you are using, perhaps in a blank onstage textbox.
re: http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=288&threadid=856292

Hope this helps.

Findal

yeah - i thought that too - about the embedding of the bold version - so i tested it out by trying to run the text box (yes it is one!) with arial instead - and still to no avail

also i tried this out yesterday in a different flash file - that one had one text box and three different possible texts that could be loaded in - the one set to lead when the swf first runs did not use the <b> tags to format - but all of the subsequent buttons which changed the text (using the exact same actionscript code) when clicked displayed the text using the formatting

ok - i worked it out - thanks very much for the link!
turns out i had to create two versions of the font in the library - normal and bold!
I was tearing my hair out over that one!
muchas gracias!