Sunday, November 29, 2009

Dynamic Text Loading

EDIT: Okay, for some reason the embedded .swf couldn't locate the .txt file in the same directory. So, here's a link to a version that works.
Remember, use the arrow keys to move the letter origin point.

Alright, here we have another old random experiment from a few months back. Basically what we have here is a .swf pulling in text information from an external .txt file. Every half a second or so, we pull the next character from the text file and shove it into a new dynamic text field. This text field is inside a movie clip that simply fades over the course of a few seconds.

Simple stuff here, but it amuses me! But then, so do sparkly objects and keys, so...

Anyway, you'll find the .as file below (that houses the origin point's controls) and the .fla containing the code. The "testTxt.txt" is the text the .swf pulls from, so if you want to save these files to your local machine, be sure to grab that little guy, too.

ALSO, you may wonder why I have my loadVars line in the onEnterFrame function...sure, it costs a little more computation, BUT this allows for instant updating. You could have this .swf open, modify and save the .txt file, and BAM! The .swf instantly reflects the changes made without have to recompile. Slick, eh?

text file
.fla source
.as source

1 comment:

  1. I can see this having quite a few pretty uses. Like especially if it moved across the x or y axis over time, that'd be killer. But yeah you basically just coded one of my fav text effects from after effects, and I always like staying 100% in flash vs the necessity of incorporating flv's from ae from time to time. Takes up time. TIME.

    ReplyDelete