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¶m2=value2
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.












