|
|
|
|
Back to Bluesfear |
|
Flash - Loading External Text
Written by Chris aka Solaris
|
Loading external text into flash has so many advantages. Consider this, trying to update a site every time something new happens. It would kind of get monotonous to have to edit the .fla every time this occurs. Using a text file is both easier to edit and alot faster. Doing so isnt as difficult as it seems either! It's actually QUITE easy and you can memorize the steps very quickly!
You can use a different font, but for now, use times new roman. This insures you can read what you have typed. Now after that, add a scrollbar from the components panel. Drag it to the right of the text field. It should attach itself and resize to make up for the text box. After you have completed that, open frame one actions. Place this script inside: |
| loadVarsText = new loadVars();
loadVarsText.load("test.txt"); loadVarsText.onLoad = function(success) { if (success) { trace("Doc Loaded"); scroller.text = this.var1; } else { trace("not loaded"); } }; |
|
As you may have noticed, the text we will be loading will be called "test.txt"
Later you can change this to your preferred text name. Now that we have established the scripting, we need to create our text document, It also HAS to be a txt file. Include this paragraph, along with any edits you might want, edit everything except the var1=. That is needed when loading the data into flash. As you may have noticed, the text we will be loading will be called "test.txt" Later you can change this to your preferred text name. The "trace" shows a message in the output window in flash mx,
this will not be seen when viewed in a player or browser. This just insures
that the loading of the text was successful when debugging. |
| var1=Hey guys this is a test.Hey guys this is a test.Hey guys this is a test.Hey guys this is a test.Hey guys this is a test.Hey guys this is a test.Hey guys this is a test. |
| As I mentioned earlier, make sure the text document
is named "text.txt". Make sure you export the swf where the text
file is, this makes it so much simpler.
You're done! Now make sure your text document is where your swf is or it wont load. If you have any problems, look below for a possible solution. Solutions My computer gives an error.
|
Back to Bluesfear
Digital Art
2000, 2004© BlueSfear