Home arrow Flash arrow Page 2 - 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 / 107
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 - Creating text fields at runtime
(Page 2 of 6 )

You can create an empty text field on the Stage at runtime using the createTextField()method of the MovieClip class. The new text field is attached to the Timeline of the movie clip that calls the method. The createTextField()method uses the following syntax:

movieClip.createTextField(instanceName, depth, x, y, width, height)
Example:
_root.createTextField("sample_txt", 1, 0, 0, 200, 150);
 

The above example creates a text field with instance name “sample_txt”, 200 pixels wide and 150 pixels high at location (0,0) and a depth of 1.

You use the instance name specified in the createTextField()call to access the methods and properties of the TextField class.

After creating the text as shown above, you can set some of its properties as shown below:

sample_txt.multiline = true;
sample_txt.wordWrap = true;
sample_txt.autoSize = true;
sample_txt.html = true;
sample_txt.background = true;
sample_txt.backgroundColor = “
0x003366”;
test_txt.text = "Sample text field created with
createTextFieldmethod
of movie clip class";

You can use the TextField.removeTextField()method to remove a text field created with createTextField(). The removeTextField()method does not work on a text field placed by the Timeline during authoring.

The following are the default properties that will be applied when creating a text field using the createTextField() method of movie clip class:

font = "Times New Roman"
size = 12
textColor = “0x000000”
bold = false
italic = false
underline = false
url = ""
target = ""
align = "left"
leftMargin = 0
rightMargin = 0
indent = 0
leading = 0
bullet = false
tabStops = [] (empty array)
 

Note that the default font property on the Mac OS X is Times.


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 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials