Ever wanted to be able to display multi-column text in Flash? What about text that spans multiple arbitrary text fields? Sure, Adobe’s Text Layout Framework will let you display multi column text, but it’s still in beta, not to mention that it’s a big, robust framework.
TextFlowLite is a simple, light-weight class that works in Flash Player 9 with standard text fields. It takes one line of code to link any number of text fields together so that the overflow of each textfield runs into the next. Likewise, it’s one line of code to change the text, or reflow it if the textfields are resized.
import com.gskinner.text.TextFlowLite; // set up the TextFlow, by default it will use the text of the first field: var tfl:TextFlowLite = new TextFlowLite([fld1,fld2,fl3]); ... // change the text: tfl.text = "my new text"; ... // change the size of a field, and reflow the text: fld1.height += 20; tfl.reflow();
I built this class about a year and a half ago while working on the Spelling Plus Library, and had meant to release it much earlier. It is part of a set including TextFlow (adds support for orphans and widows), and TextFlowPro (which includes support for selection, editing, copy/paste). I will release the other two for free when I have time to retest and clean them up (hopefully later this week).
Here’s a simple demo:
It’s a pretty simple class, but hopefully it’s useful for someone. As I said above, I will be releasing TextFlow and TextFlowPro in the near future. You can download the source code by clicking here. As usual, the code is released under the MIT license.