Flash
  Home arrow Flash arrow Page 3 - 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  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
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 / 85
    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 - Using TextFormat Class


    (Page 3 of 6 )

    To use the TextFormat class, you first create a TextFormat object and set its character and paragraph formatting styles. You then apply the TextFormat object to a text field using the TextField.setTextFormat()or TextField.setNewTextFormat()methods.

    The setTextFormat()method changes the text format that is applied to individual characters, to groups of characters, or to the entire body of text in a text field. The text that is newly inserted, such as text entered by a user or inserted with ActionScript, does not assume the formatting specified by a setTextFormat() methodcall. To specify the default formatting for newly inserted text you need to use the setNewTextFormat() method.

    Now let's see an example of how to use the TextFormat class.

    // Create a TextFormat object

    var txtfmt:TextFormat = new TextFormat();

    // Specify paragraph and character formatting

    txtfmt.bold = true;

    txtfmt.italic = true;

    txtfmt.underline = true;

    txtfmt.bullet = false;

    txtfmt.align = “center”;

    txtfmt.color = “0xFF0000”;

    txtfmt.font = “Verdana”;

    txtfmt.url = “http://www.devarticles.com”;

    txtfmt.target = “_blank”;

    txtfmt.indent = 10;

    txtfmt.size = 24;

    // apply the TextFormat object to the text field

    sample _txt.setTextFormat(txtfmt);

    You can also apply the TextFormat object properties to a specific part of the text field as shown below.

    // applies the TextFormat object only to the first three characters of the text field

    sample_txt.setTextFormat(0, 3, txtfmt);

    You can also apply the TextFormat object properties to a specific character of the text field as shown below.

    // applies the TextFormat object only to the second character of the text field

    sample_txt.setTextFormat(3, txtfmt);

     

    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

    - 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
    - A Closer Look at Apollo`s File System API
    - Using the File System API
    - ActionScript 101
    - Flash Buttons
    - Advanced Flash Animation
    - Creating Your First Animated Movie with Flas...
    - Flash: Building Blocks
    - Building Preloaders






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