The loadVariablesNum() Method
The loadVariablesNum() method is similar to the loadVariables() method in that it loads external variables into Flash, but unlike the loadVariables() method, the loadVariablesNum() method loads the variables into a level instead of directly into a movie clip.The basic layout of this method looks like this:
Following are the parameters that loadVariablesNum will accept:
loadVariablesNum(URL, level, method);
- URL
The path to either the text file being loaded or the middleware page being called. - level
The level in the Flash player to receive the variables when they are loaded. - method
This is an optional parameter used to define the method used when transferring data to and from middleware.
It also supports the onData event as a means of announcing when data has been fully loaded.Here is an example using the loadVariablesNum() method:
1. | Create a new Flash document. |
2. | Save this document as sample-20-4.fla in the same directory as the text files you have been working with. |
3. | In the first frame on the main timeline, open the Actions panel and place these actions in it:
|
Notice that this time, we use a conditional statement to make sure that the event is not accidentally being triggered by the main timeline's initialization. Also notice that we are calling the original text file we created, not the one we used to put in an array.Figure 20.4.But the two methods we have covered in regard to loading external data are not the end. There is even a built-in object specifically designed for interfacing with external data.