Hi Guys,
I'm having a few issues with html formatted text-fields.
I have embedded the following fonts in the library and given them
linkage names Helvetica 55 Roman, 75 Helvetica Bold, Helvetica 56
Italic. Then I am using the code below to try to dynamically produce
a textfield which can be populated with text marked up with simple
html tags ( in the real application the text will come from an XML
file). My client wishes to use html as their copy writers know how to
use it.
My problem is this the tags are ignored. What is the best course of
action/ best practice in this situation? I was thinking of creating a
function to assign a bold textformat (theBold) to the characters in
the textfield. I could get the index of the text using pattern
matching in the string but that just seems a bit like over kill isn't
there a better way?
theRoman = new TextFormat("Helvetica 55 Roman", 15, 0x333333, true,
false, false, null, null, "center");
theBold = new TextFormat("75 Helvetica Bold", 15, 0x333333, true,
false, false, null, null, "center");
theItalic = new TextFormat("Helvetica 56 Italic", 15, 0x333333, true,
false, false, null, null, "center");
// create a text feild
this.createTextField('txtMain', 0, 10, 10, 300, 300);
//
txtMain.html = true;
txtMain.background = true;
txtMain.backgroundColor = 0xFF6600;
txtMain.wordWrap = true;
txtMain.embedFonts = true;
txtMain.setNewTextFormat(theRoman);
txtMain.htmlText = " Last Updated: Wednesday, <b>15 February 2006</b>,";
txtMain.htmlText += "23:48 GMT <i>E-mail</i> this to a friend
Printable version US attacks Iraq abuse images leak";
// set another text format
txtMain.setTextFormat(0, 6, theBold);
txtMain.setTextFormat(6, 15, theItalic);
James Deakin
On 7 Feb 2006, at 22:56, Nathan Derksen wrote:
Damn, I always thought that seemed a silly way to do it. After all
this time of re-calling that bloody thing every time I changed it.
Thanks for the correction, I'll go back and fix my old code :-)
Nathan
http://www.nathanderksen.com
On Feb 7, 2006, at 2:49 PM, Ian Thomas wrote:
Or call setNewTextFormat() instead.
setTextFormat() applies to the _existing_ text within the field.
setNewTextFormat() applies to any text that will be put into the
field.
This is why (Nathan) you're having to call setTextFormat()
multiple times -
calling setNewTextFormat() just once, before putting anything into
the
field, should solve that issue.
HTH,
Ian
On 2/7/06, Nathan Derksen <[EMAIL PROTECTED]> wrote:
You need to re-apply setTextFormat() every time you change the .text
or .htmlText properties of a text field:
<snip>
percent.text = percentNum;
percent.setTextFormat(ldrFormat);
<snip>
I tried this out with your code, and it worked fine afterwards.
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com