Load Parameters From a Text File to Flash Animation Using loadVariables() function

This tutorial was written for the Flash Designer software, which allows you to create flash animations in a much easier way than by using Macromedia Flash. You may get Flash Designer here.

Text file must be in the format:

param1=value1&param2=value2

t1012.txt

Load text file by using:

loadVariables("t1012.txt");

Usually in Frame's ActionScript.

Create 2 edit fields for param1 and param2. Name fields Edit1 and Edit2. Create "Set Variables" button. Use the following ActionScript code for button's OnUp (or OnClick) event:

Edit1 = param1;
Edit2 = param2;

To complete the tutorial:

1. Create a folder and download t1012.txt file to the folder.

2. Launch Flash Designer. Choose "Frame" > "Frame Size" to set movie size (300 x 200).

3. Choose "Frame" > "ActionScript" and use the following code:

loadVariables("t1012.txt");

4. Choose "Edit Field" tool and draw 2 edit fields.

5. Choose "Select" tool. Double click each edit field and change "Variable name" to "Edit1" and "Edit2".

6. Choose "Button" tool and draw a button below edit fields.

7. Choose "Select" tool. Double click the button to edit OnUp event. Select "actionscript" and enter the code. Click OK.

8. Change frame duration to "stop" .

9. Choose "File" > "Export SWF file" and export the file to the same folder with txt file.

10. Choose "File" > "Export HTML Page", a page with Flash animation should pop up in a new browser window.

11. The script will not work in preview mode unless you put txt file in the temp folder.


Close    To Top
  • Prev Article-Flash:
  • Next Article-Flash:
  • Now: Tutorial for Web and Software Design > Flash > Action Script > Flash Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction