Your Ad Here

December 30, 2009

Loading Text in Flash from External File

Name : Loading Text from external text file

Category : Advanced
Actionscript : 2.0

In Macromedia Flash text can be loaded from external text file, from .txt files. This is very handy while creating a website with Dynamic content, so you have to edit the text file only and it will be loaded accordingly. In this tutorial you will learn how to load external text from external text document.

1- Create a new notepad text file (.txt), save the file named as "doc.txt" and write in it:

text_myne=I am learning how to load external text file in flash from haider rizvi blog.

2- Create a new flash document and save it in the same folder in which the text file is.

3- Create a text field with dynamic attributes and set its name in the Properties box as “my_txt”

4- Expand the text field to approximately 300x200 size.

5- Open the Components window. Goto: Window > Components

6- Expand “User Interface” by clicking on it.

7- Find “UIScrollBar” in it and Drag and Drop it to stage, besides the text filed you have created.

8- Place the “UIScrollBar” to the right side of the text field so that it gets attached with it.

9- Now create a new layer and name it as “actions”.

10- Select the first frame of the actions layer (which is currently empty) and open up the actions panel. Write the actions in it as follows:

myData = new LoadVars();
myData.onLoad = function() {
my_txt.text = this. text_myne;

11- All Done. Now test the movie by pressing Ctrl+Enter.

*Note: You can edit the appearance of text from the text field properties.


Please use sensible language.....!