Flash
  Home arrow Flash arrow Page 2 - 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 / 94
    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 - 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.

    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

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







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