Flash
  Home arrow Flash arrow Page 4 - Working with Text and HTML in Flash
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Working with Text and HTML in Flash
By: Adi Reddy Mora
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 92
    2005-05-04

    Table of Contents:
  • Working with Text and HTML in Flash
  • Creating text fields at runtime
  • Using TextFormat Class
  • Formatting Text using HTML
  • Supported HTML tags
  • Embedding media in text fields

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with Text and HTML in Flash - Formatting Text using HTML


    (Page 4 of 6 )

    Flash Player supports a subset of standard HTML tags such as <b>, <p>and <li>that you can use to style text in any dynamic or input text field.

    Flash Player also supports the <textformat>tag, which lets you apply paragraph formatting styles of the TextFormat class to HTML enabled text fields.

    To use HTML in a text field, you must enable the text field’s HTML formatting either by selecting the Render Text as HTML option in the Property panel or by setting the text field’s htmlproperty to true using ActionScript. To insert HTML into a text field use the TextField.htmlTextproperty.

    For example, the following code enables HTML formatting for a text field named sample _txtand then assigns some HTML to the text field using font tags.

    sample_txt.html = true;
    
    sample_txt.htmlText =
    "<font face = 'Times New Roman' size = '24' color = '#003366'>
    This is how you assign HTML text to a text field.</font>";

    Attributes of HTML tags must be enclosed in double (") or single (') quotation marks. Attribute values without quotation marks can produce unexpected results, such as improper rendering of text. For example, the following HTML snippet cannot be rendered properly by Flash Player because the value assigned to the alignattribute ( left) is not enclosed in quotation marks:

    sample_txt.htmlText = "<p align=left>This is left-aligned text</p>";
    

    If you enclose attribute values in double quotation marks, you must escape the quotation marks ( \"). Either of the following examples are acceptable:

    sample_txt.htmlText = "<p align='left'>This uses single quotes</p>";
    
    sample_txt.htmlText = "<p align=\"left\">
    This uses escaped double quotes</p>";

    It’s not necessary to escape double quotation marks if you’re loading text from an external file. It’s necessary only if you’re assigning a string of text in ActionScript.

    More Flash Articles
    More By Adi Reddy Mora


       · writing html-tags in a textarea field for printing (via database)in a flash-field...
     

    FLASH ARTICLES

    - More on Nonpersistent Client-Side Remote Sha...
    - Nonpersistent Client-Side Remote Shared Obje...
    - Using the Decorator Pattern for a Real Web S...
    - Using Concrete Decorator Classes
    - Delving More Deeply into the Decorator Patte...
    - The Decorator Pattern in Action
    - A Simple Decorator Pattern Example
    - Decorator Pattern
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications
    - ActionScript in Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT