Read From A Text File in SWiSHmax
Digg! This Page
Step 1Create a new movie. Make its size roughly 480 by 320, with a frame rate of 12.

Step 2
Select the text tool
and draw a textbox on your palette. Make it dynamic text and vector font. Then for each of the options use the following options.


Make sure you have named the text field as "message" and on the advanced option make the varible name as "mymessage"
Step 3
Now right click the textfield in the "Outline" and choose Grouping -> Group As Sprite.

Step 4
With the "sprite" selected in the "Outline" menu select "Script" in the layout palette and now we need to make the script read from a text file. So to do that change the Script mode to Expert and first set the script to start when the flash file loads.
onLoad () {
}
Now with the script starting when the flash file loads, we need to tell it to read the text file. To do that we need to use this line.
this.loadVariables("dalehay.txt");Here is a breakdown of that line, just incase you're myth'd about it. "this" basically means this flash file and "loadVaribles("dalehay.txt");" means load all the varibles (of which the one we're using is "mymessage") also the filename is basically the text file where the varibles are stored.Step 6
So altogether that should look like this.
onLoad () {
this.loadVariables("dalehay.txt");
}That is all for that. So File -> Export -> SWF + HTML and save it to your desktop.Step 7
Finally create a text file in the same place as the SWF and HTML files and name it whatever you picked for the "loadVariables" bit. For mine I'd use dalehay.txt and within your text file you need to start it with.
&mymessage=Everything starts with a ampersand then it's followed by the varible name then an equals sign. After the equals sign is what will get sent through from the text file to the flash file. After it place one more ampersand (&), so it should look something like this.
&mymessage=Hello everyone, my name is Dale Hay&Step 8
Save the text file and upload (or view it on your computer) and you should get something like this.




