Dynamic Text In Flash
 

Dynamic Text In Flash

Regular Feature: How-To's Day

Dynamic Flash doesn’t have to hurt, I promise.

Let’s face it, as a designer you probably don’t have time to make minor updates to every web site you’ve ever worked on, which means you have to make this process as easy as possible for your clients. This is why we create dynamic sites. I’ve seen countless tutorials explaining dynamic text in Flash go on and on for pages with several necessary companion files, all of which are overkill. In a few painless steps (six, in fact) you can make updating the copy of your Flash movie as uncomplicated as editing a .txt file.

Read more on Dynamic Text In Flash…

Regular Feature: How-To's Day

Dynamic Flash doesn’t have to hurt, I promise.

Let’s face it, as a designer you probably don’t have time to make minor updates to every web site you’ve ever worked on, which means you have to make this process as easy as possible for your clients. This is why we create dynamic sites. I’ve seen countless tutorials explaining dynamic text in Flash go on and on for pages with several necessary companion files, all of which are overkill. In a few painless steps (six, in fact) you can make updating the copy of your Flash movie as uncomplicated as editing a .txt file.

  1. Create a .txt file with your text to be dynamically loaded, and name it mytext. At the beginning of this text type: textField= You have now declared a variable name for this text. What’s a variable? A variable is a container that holds information, such as a name, a URL, or whether or not a button’s been clicked.
  2. Create a new Flash movie, and save it in the same folder as your .txt file. With the text tool in the toolbar, draw a new text field onto the stage.
  3. In the properties inspector change the drop down on the left from Static Text to Dynamic Text. Make sure you’ve selected Multiline and not Single Line, and Anti-alias for readability. You don’t need to Anti-alias for bitmap fonts, but that’s another tutorial.
  4. Again in the properties inspector type textField in the Var field. You’ve now assigned a variable name to this text field, this must be the same name you assigned in your .txt file.
  5. Create a new layer on the main timeline called Actions. Select the first frame, and open the Actions panel (F9.)
  6. Type: loadVariables("mytext.txt", this) You can also choose Global Functions > Browser/Network and doubleclick loadVariables, and then type mytext.txt into the parantheses. You must include quotation marks around the name of your text file. This tells Flash to load mytext.txt into this timeline.

That’s it. Test your movie, and you should see the text from your .txt file in your flash movie. If not, go back to your movie and make sure you have the text set to a color that contrasts with your background color. Flash does have limited support of basic html tags within .txt files, but it’s buggy at best in MX 2004. If you’re using Flash 8, the Flash Player 7 narrowly supports CSS. Whatdoiknow.org lists the supported CSS properties. Check back for follow up tutorials on how to embed fonts in Flash, and using Flash’s XML Object for parsing. As always, if you have any problems or comments feel free to email me at bethdean (at) designorati (dot) com.

How-To’s Day is a regular Designorati feature in which we give you fresh tutorials across all of Designorati. How-To’s Day happens every other Tuesday.

Subscribe to the Discussion Surrounding This Article
  1. But once the text is loaded, how does one manipulate it. Does this only display text, or is it possible to put it into a variable and parse it.

    For example, When I create a Dynamic Text box named “MyText” and then set the Variable to MyVariable and load a text file with the first line:
    MyVariable = this is text

    Then I cannot get the text either by
    Var_for_loaded_text = _root.MyVariable
    or by
    Var_for_loaded_text = _root.MyText.text
    or by
    Var_for_loaded_text = _rott.MyText.MyVariable

    Is there anyway to get the text once it is loaded this way?

    Thanks

    10 May 2006

  2. my swf file fatching data from txt file when i run it locally. but when i m online no data from txt file is coming.

    26 September 2006

  3. esto funciona perfectamente

    31 October 2006

  4. Hello,

    I’d like to know how to get my dynamic text to call in css from the text file? Or some other way to get the text to be able to use html tags etc, so I can style it a bit.

    thanks!
    Dave

    30 January 2007

  5. Hello,
    I’m using a similar code as you explained.
    It works perfectly when I test it localy, also when I change the text in the text-file.
    But when I test it online I can change the text in the text file as much as I want but it doesn’t change, not even when I refresh the page.
    Do you have any idea how to fix this?

    01 March 2007

  6. Hi.

    I was trying to get the data from the .txt file.
    Once get the value from the .txt, it will run to another scene.
    I tried many times but i couldn’t solve.
    Do you mind to guide me?

    myData= new LoadVars();
    myData.load(“details.txt”);
    point.text = this.totalpoint;
    myData.onLoad = function(){

    if((point> 8000) && (point 7999) && (point 5999) && (point

    08 October 2007

  7. if((point> 8000) && (point 7999) && (point 5999) && (point

    08 October 2007

  8. tyuyu

    26 May 2008

  9. Instead of loadVariables(“mytext.txt”, this) try
    loadVariables(“http://www.website.com/mytext.txt”, this)

    14 February 2009

  10. i am new to flash action scripts :(

    i have created to dynamic text, when i say preview they should rotate

    plz help me in this

    11 March 2009

  11. Nice. I tryed many tutorials before with no success. Now, my problem is that have the character “&” in my .txt file, and flash omit the remaining text, even if i disabled HMTL tags in the dynamic text properties. Any suggestions?
    Thanks.

    27 April 2009

  12. THANKS!

    01 June 2009

  13. Hey!!… Hope you can help

    I need to add a scroll bar to dynamically created MovieClip!! is that possibe ?

    The Scroll bar should appear only on some condition and should disappear vise versa .And i am creating everything dynamically. If you can help me please do ping me on ma mail id.

    Any Idea would be better!!!

    10 August 2009

  14. thank you sooo much! this has been really helpful… is there a way to setup the lineheight of the dynamic text loaded? I’m using AS 2, thank you!

    06 December 2009

  15. i am making a dynamic flash of breaking news.flash is already designed and dynamic text is working properly but i have a problem that i want to load the text from .txt file line by line means at a time one line display in flash and second time second line display in flash and i want to run this loop continues.

    So please help me and reply.
    my email id is “cprakash338@yahoo.com”

    29 August 2010

  16. Hi, thanks for your simple tutorial. It woks ok but
    I’m making a Christmas card and I need to
    personalize the message text for each card I want to sent… lots of them.
    Can flash recover information from access or excel?
    I’ll have 3 different fields: to, message and from.

    any idea?
    please help me

    02 September 2010

*Enter Your Name (Required)
*Enter Your Email Address (Required and Kept Confidential)
Enter Your Web Address (Optional)
An asterisk (*) in the field name indicates required information.

We reserve the right to edit or delete comments for any reason.

Suggested Links

domain registration

Worldlabel is a source for equivalent Avery® labels sizes and free label templates for designing.