This is a discussion on Loading Variables in Flash within the Graphics forums, part of the Tutorials category; LOADING VARIABLES IN FLASH The loadVariables action reads data from an external file. This is useful when you need to ...
LOADING VARIABLES IN FLASH
The loadVariables action reads data from an external file. This is useful when you need to read data from a text file or you are working with data from a CGI, Active Server Page (ASP), or Personal Home Page (PHP) script. Your Flash movie and the data must be located in the same sub-domain if you are accessing the data using a Web browser.
The syntax for load variable is
loadVariables (url, location, variables);
The url argument is used to specify the absolute or relative URL of the file containing the variables you want to load. The location argument is used to specify the level or target path that will receive the variables. The variables argument is used to specify the method you want to use to send variables. Choose from get and post.
Set up the data you want to load by entering it in the following format:
Use variableName to specify the name of the variable. Use value to specify the value you are assigning to the variable. Separate each variable/value pair with an &. The variable names in your text file must match the variable names in your movie.
Certain characters cannot be read directly from a text file. You must use URL encoding for these characters. For example, if your text file includes temperature=+15, ActionScript will read it as temperature=15, dropping the plus. The URL code for the + is %2b. To have ActionScript read the entry correctly, type temperature=%2b15.
ActionScript sometimes requires substituting loadVariable with loadVariableNum. If you are entering your script using the Normal mode, this substitution is done automatically.
Follow the below steps for loading the variable:
1) Select the frame, button, or movie clip to which you want to add ActionScript.
This example uses a button.
2) Click Window from menu bar and click Actions to open the Actions panel.
3) Load the variables.
4) If you connect the variables with dynamic text boxes, you can display the values the variables return to the user.
5) Close the Actions panel.
6) Click Control from menu bar and then click Test Movie to move to the text environment.
7) Click the button to test your movie.
8) Each of these boxes is a dynamic text box.
9) When you click the button, the variables load.
You can also use the escape function to convert an expression to URL-encoded format. The syntax for the escape function is escape(expression). Use the expression argument to specify the expression you want to convert to URL-encoded format.
You can also use the unescape function to convert an expression from URL-encoded format to ASCII characters. The syntax for the unescape function is unescape(expression). Use the expression argument to specify the expression you want to convert from URL-encoded format to ASCII.