Unregistered Avatar

Reply

Loadiing External Text in Flash


 
LinkBack Thread Tools Display Modes

  #1 (permalink)  

Old 01-21-2007, 09:12 AM

Loadiing External Text in Flash

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!

Start off by creating a dynamic text field in flash. In the field below the type of field the text box is, type "scroller". this changes the instance name and we can use this to communicate with later. Be sure also that your text field is set to "Multiline". If you have a large amount of data, it will not show up in the field.

You can use a different font, but for now, use times new roman. This insures you can read what you have typed. After you have completed that, open frame one actions. Place this script inside:


Code:
 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.

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.

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.



Quote:
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.
__________________

Last edited by Solaris; 01-21-2007 at 09:20 AM.
Solaris

Solaris is offline flash addict

Join Date: Jan 2007

Location: Charlotte, NC

Posts: 20

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
El Diablo de Lag! The Anti-Bob The VOID! 5 05-01-2006 09:42 PM
Flash tuts: Suggestions missionsix 3D Art and Animation 1 06-24-2004 06:15 PM
iCandy Flash Banner missionsix Discussion Lounge 2 06-09-2004 07:24 AM
Flash Forum Site Fluffy_monkey Discussion Lounge 0 06-04-2004 12:04 PM


All times are GMT -7. The time now is 02:39 PM.