SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    formatting a textfield

    I have a textfield in flash whose data is being pulled from an xml file. I need to format the text and I came across two methods for that:

    txtField.setTextFormat(txtFormat);
    and
    txtField.htmlText = ...;

    Text formats have the functionality I want(being able to set font, size, bold, color) but they apply the same format to all the text in the field.

    HTML text doesn't seem to recognize certain tags, like the font tag.

    So does anyone know how I can format text to be something like this for example:

    Header text

    Body text with bold etc.

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    htmlText will recognize the font tag and textFormat can be set to only certian areas of the text.
    Try this:
    Code:
    createTextField("myText", 1, 0, 0, 200, 30);
    createTextField("myText2", 2, 0, 40, 200, 30);
    myFormat = new TextFormat();
    myFormat.font = "Arial";
    myFormat.size = 12;
    myFormat.color = 0xFF0000;
    
    myText2.text = "i am some body text";
    myText2.setTextFormat(myFormat);
    
    myFormat.bold = true;
    myFormat.color = 0x000000;
    
    sIdx = myText2.text.indexOf("body");
    eIdx = sIdx + 4;
    myText2.setTextFormat(sIdx, eIdx, myFormat);
    myFormat.size = 16;
    myText.text = "Header 1";
    myText.setTextFormat(myFormat);

    Or this for htmlText

    Code:
    createTextField("myText", 1, 0, 0, 200, 30);
    createTextField("myText2", 2, 0, 40, 200, 30);
    myText.html = true;
    myText2.html = true;
    myText.htmlText = "<font face=\"arial\" color=\"#000000\" size=\"18\"><b>Header 1</b></font>";
    myText2.htmlText = "<font face=\"arial\" color=\"#FF0000\">i am some <font color=\"#000000\"><b>body</b></font> text</font>";

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2002
    Location
    Fort Lauderdale
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome. I wasn't using quotes in my font tag. Thanks

    www.unpossiblemedia.com - A Fort Lauderdale based multimedia company.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •