Flash
  Home arrow Flash arrow Page 6 - Flash MX Pro 2004 - Text Area Component
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

Flash MX Pro 2004 - Text Area Component
By: Jefferis Peterson
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 52
    2004-01-26

    Table of Contents:
  • Flash MX Pro 2004 - Text Area Component
  • Transition
  • The TextArea Component – First Encounter
  • Bugs
  • Using the TextArea
  • Steps

  • 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


    Flash MX Pro 2004 - Text Area Component - Steps


    (Page 6 of 6 )

    To create a new TextArea which loads a text file, I am going to give you a method which worked for me. It requires three separate documents, which I will not type out in their entirety. I will just give you a sample.

    1) Drag a TextArea Component from the component library onto your Flash stage and give it an instance name of myText in the Properties Inspector.

    2) 2. In a text writer or Dreamweaver, Create a CSS file and name it sample.css. I started by using the Text Enhancement Tutorial provided by MM in Flash 2004. One thing that is important to note is that most of the styles use NON-HTML tags. The reason for that is that Flash does not interpret many standard tags. However, it seems to have no problem with CSS tags created from new words like headline or italicy. It is also important to use the display:block definition if you want paragraphs. Using display:block allows you to format your text without using excessive line breaks, which can cause problems. And if you want to change the color of your text, the CSS file is the best and easiest way to do that. Define your text colors here! Here is part of my sample.css:


    headline {
      color
    #FFFFFF;
      font-family: Arial,Helvetica,sans-serif;
      font-size: 16px;
      font-weight: bold;
      display: block;
    }
    mainBody {
      font
    -familyArial,Helvetica,sans-serif;
      color
    #FFFFFF;
      font-size: 12px;
      display: block;
    }
    italicy {
      font
    -familyArial,Helvetica,sans-serif;
      color
    #FFFFFF;
      font-size: 12px;
       font-style: italic;
      display: inline;
    }
    biline {
      font
    -familyArial,Helvetica,sans-serif;
      color
    #FFFFFF;
      font-size: 13px;
      font-style: italic;
      display: inline;
    }
    {
      font
    -familyArial,Helvetica,sans-serif;
      color
    #cccccc;
      font-size: 12px;
      display: inline;
      text-decoration:underline;
    }

    3) Create a text file with CSS defined tags, and place all your text on a single line. Save this file as loadtext.xml. At this point, you could create an HTML file instead, and it should not pose a problem. However, using the XML Class definition, an XML file just seems more consistent to me. Here is a sample of my XML text file:


    <loadtext>
    <headline>Digital Video and Sound</headline>
    <mainBody>
    <biline>Flash StreamingQuickTimeRealVideo/Audio
    CD
    /DVDWeb StreamingAnimation/VoiceOriginal
    Music
    </biline>
    </mainBody>
    <br>
    <subheadline>Digital Video For Web Sites</subheadline>
    <mainBodyDigital Video and Animation Services are 
    provided by Peterson Sales in cooperation with DVI 
    Studios… 
    </mainBody
    </loadtext>

    4) Finally, add the following code to a frame on the stage, and for safety's sake, make sure the component is visible on the stage in the same time frame as the code. (Some of these variables can be changed in the Property Inspector, but what is written on the stage overrides the Inspector's settings.)


    // set properties for a TextArea component on the 
    // stage with instance name "myText"
     
    myText.html true
    // allows html tags and XML styles to be displayed
     
    myText.wordWrap true
    myText
    .multiline true
    // makes it scrollable
     
    loadtextStyle = new TextField.StyleSheet(); 
    // create a new instance of a Class StyleSheet
     
    loadtextStyle.load("sample.css"); 
    // loads your CSS document with defined tags
     
    myText.styleSheet loadtextStyle
    // applies your new XML styles to myText
     
    myText.setStyle("backgroundColor","0x000099"); 
    // sets the background color 
    // (Text color is set in the CSS.)
     
    loadtextContent = new XML(); 
    // create a new instance of an XML Class
     
    loadtextContent.ignoreWhite true;
    loadtextContent
    .load("loadtext.xml"); 
    // identifies the file to be loaded
     
    loadtextContent.onLoad = function(success)
    {
            
    if(success)
            
    {
             myText
    .text loadtextContent
    // loads the file into the TextArea 
            }
    }

    Conclusion

    There you have it. It is beyond the scope of this tutorial to explain the XML structure or the reasons behind the Class requirements for this component. I am learning as I go and awaiting some good third party books on ActionScript 2. But this procedure works and is given to get you started. I defy anyone to tell me that this is easier than adding text in Flash 5 or MX. It may be more controllable and more powerful, but there are many more steps involved. The one upside to this new structure is that once you have defined a style set, you can govern the appearance of your entire Flash site by changing just one file, and by loading the content file from a website, you can change the text, HTML, or XML file without  opening Flash. But this complex situation for a basic need like text control is still 2 steps forward and 2 steps back.

    I hope this little tutorial saves you from some of the frustration and pitfalls I experienced with this new version of Flash as we all await better documentation for the new features.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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 4 Hosted by Hostway
    Stay green...Green IT