Home arrow Flash arrow Page 3 - Working with Text and HTML in Flash
FLASH

Working with Text and HTML in Flash


There are a variety of ways to manipulate text and HTML with Flash that allow you to expand the capabilities of your website. Adi Reddy Mora goes over some of the most common ones.

Author Info:
By: Adi Reddy Mora
Rating: 4 stars4 stars4 stars4 stars4 stars / 108
May 04, 2005
TABLE OF CONTENTS:
  1. · Working with Text and HTML in Flash
  2. · Creating text fields at runtime
  3. · Using TextFormat Class
  4. · Formatting Text using HTML
  5. · Supported HTML tags
  6. · Embedding media in text fields

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

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);

 


blog comments powered by Disqus
FLASH ARTICLES

- More Top Flash Game Tutorials
- Top Flash Game Tutorials
- Best Flash Photo Gallery Tutorials
- The Top Flash Tutorials for Menus
- 7 Great Flash Tutorials
- Adobe Creative Suite 5.5 Now Available
- Critical Flash Vulnerability Heats Up the Web
- 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

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials