Importing a text file in to Flash

Importing a text file in to Flash

This tutorial with guide you through how to import a text file in to your flash file by pressing a button. This is useful for flash websites and offers an easy way to update the content within the flash website, rather than editing the SWF itself.

1. Open Flash and create a new document or your existing document that you wish to implement this in to.
2. I will be writing this tutorial based on making a new SWF altogether, so people that wish to implement this in to their current designs will have to think around some of the steps logically.
3. So on with the tutorial. Firstly we will create the button (I am not making a fancy button for this tutorial)

Go to Insert » New Symbol


For the button name type anything, I will use "button".

Set the Type to Button

6. Press OK.

Now using the rectangle tool, set the colours to whatever you want, I am just using a basic blue background with no border.

8. Draw a rectangle, but remember not to draw it too big as we need room for our text area.
9. Now press Scene 1 which is just above the timeline, this will bring us back to the main file
10. From the Library (Ctrl + L) drag and drop the button in to the scene and move it to one of the sides
11. Now select the text tool and drag out a small text area, we will expand it later on.

In the properties panel (Ctrl + F3) set the Text Type to Dynamic Text and set the font size to whatever you want. Set the Line Type to Multiline and select the Selectable button For the Variable name type in content.

For the instancename, type something relevant, for the purposes of this tutorial I will call it myTxt

If you wish to use HTML tags to create a hyperlink within the text area, click the button that says Render text as HTML


Now you can drag out the text box to the area that you wish it to cover.


Now we need to add the code to make the text file be imported


Click the Button, with the Select Tool (V)


Now bring up the actions panel (F9)


And either Copy this in, Type it in, or use the menu to select the options:

on (press) {loadVariablesNum("flash.txt","0");


"flash.txt" is the name of the text file you wish to put in to the flash file.


Now create a new file called flash.txt and put this in the same directory as your flash file


In your flash.txt, type content= followed by the text you wish to put in your flash file.


Now press Ctrl + Enter to preview, press the button and the text should be displayed


FLA - TXT - SWF - Whole source in ZIP