tlfMarkup ANYONE?

Well, so far I’m something like 0/4 in getting any help from this forum. I must be good at stumping everyone.

Latest issue:

I have this project where text appears to write itself. I achieve this obviously through layer masks.

What I’ve done is automate this through actionscript where instead of creating individual textboxes manually and tweening their masks, I create ONE textfield in a MovieClip. I can type a paragraph of text into this textfield and when the timeline reaches the clip, code is executed that does the following:

breaks the paragraph of text into separate text containers that have the lines of text within them. Each of these textfields then has a mask that tweens itself when the preceding line of text’s mask completes its tween.

I hope that all makes sense.

The problem is . . . what about local formatting? ie, color and sub/super scripts. Originally I was using htmlText for color (worked great), but the sub/super script is a deal breaker.

I’ve been trying to do this with tlfMarkup, but it puts the entire paragraph of text in each field instead of the individual lines. The good news is that it keeps the formatting.

Any ideas? I’ll attach the code. You need to create a MovieClip with a textfield in it called “allText”. On keyframe one, put the following code . . .
init(whatever keyframe you place the movieclip on)

You’ll also need a movieclip in your library that’s a plain rectangle, aligned to stage on the upper right hand corner. Export it as arrowMask();

(I have a controller skin for the movieclip with a scrub bar in the original project that the viewer can use to scrub back and forth through the animation . . . hence the remaining code at the bottom)

package {

import fl.text.*;
import flash.display.MovieClip;
import flash.text.TextFieldAutoSize;
import fl.text.TLFTextField;
import flash.text.TextFormat;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.compose.IFlowComposer;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.ParagraphElement;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.*;
import flashx.textLayout.formats.*;




public class blackbunnyTextBlue extends MovieClip 
{
	public var textString;
	public var X;
	public var Y;
	public var Lines;
	public var fmt:TextFormat = new TextFormat();
	public var spaceBetween = 0;
	
	public var Arrow;
	public var hasFired = false;
	public var aMask = new arrowMask();
	public var startFrame;
	public var totalPixels;
	public var endFrame;
	public var main ;
	public var Parent;
	public var masks = [];
	
	public function blackbunnyTextBlue() 
	{
		
	}
	public function init(frameNumber):void
	{
		//only fire once unless scrubber is backed up
		if(hasFired == false)
		{
			
			Parent = MovieClip(parent);
			
                            //format the existing field
			allText.autoSize = TextFieldAutoSize.LEFT;
			allText.wordWrap = true;
			allText.visible = false;
			
			//format new field
			var temp = new TLFTextField();
			temp.htmlText = allText.text;
			temp.autoSize = TextFieldAutoSize.LEFT;
			temp.width = allText.width;
			temp.wordWrap = true;
			Lines = temp.numLines;
			
			textString = allText.text;
			X = allText.x;
			Y = allText.y;
			
			
			
			startFrame = frameNumber
			
			for(var i:int = 0; i < Lines; i++)
			{
				//for every line in the new text field, create a new single line field
				//with a line of text in it, a mask for it, and add them to the stage
				var lineText = allText.getLineText(i);
				var lineMetrics = allText.getLineMetrics(1);
				
				var Txt:TLFTextField = new TLFTextField();
				Txt.border = false;
				Txt.wordWrap = true;
				Txt.htmlText = lineText;
				Txt.defaultTextFormat = fmt;
				Txt.autoSize = TextFieldAutoSize.LEFT;
				Txt.width = allText.width;
				Txt.x = X;
				Txt.y = Y ;
				Txt.embedFonts = true;
				Y = Y + (lineMetrics.height) + spaceBetween;
				addChild(Txt);
				
				
				var maskOne = new myMaskText();
				maskOne.addEventListener(Event.ENTER_FRAME, engageInit);
				maskOne.x = Txt.x - 10;
				maskOne.y = Txt.y - 10;
				//mask init calculates what frame mask should move, end, and how far to move
				maskOne.init(i, startFrame);
				addChild(maskOne);
				masks.push(maskOne);
				//Set the mask to content
				Txt.mask = maskOne; 
			}
		}
		hasFired = true;
		//listens for scrub bar backing up
		addEventListener(Event.ENTER_FRAME, checkFrame);
	}
	
	//only add the tween listener to the masks when their start frame has been passed by the scrubbar
	//this is trying to imitate the init code on a particular timeline
	public function engageInit(evt):void
	{
		if(Parent.currentFrame >= evt.target.startFrame && evt.target.hasFired == false)
		{
			evt.target.addEventListener(Event.ENTER_FRAME, tweenMe);
			evt.target.hasFired = true;
		}
	}
	
	
	public function tweenMe(evt):void
	{
		
		var masterFrame;
		masterFrame = Parent.currentFrame;
		var aMask = evt.target;
		
		//if the scrubber is between the start frame and end frame, tween the mask according to 
		//the timeline's position
		if(masterFrame >= aMask.startFrame && masterFrame <= aMask.endFrame)
		{
			var ratio = -((aMask.totalPixels)*(aMask.startFrame - Parent.currentFrame)) / 24;
			
			var tweenMe:Tween = new Tween(aMask, "x", None.easeOut, aMask.x, ratio, 1, false);
			
		}
		//if the scrubber is dropped past the endFrame, move the mask to the end position
		else if(masterFrame > aMask.endFrame)
		{
			aMask.x = aMask.totalPixels;
			
		}
		//if the scrubber is dropped before the beginning frame, remove the event listener
		else if(masterFrame <= aMask.startFrame && aMask.hasFired == true)
		{
			aMask.x = aMask.startX;
			removeTween(aMask);
		}
	}
	
	//remove mask tween listener if scrub bar is dropped before its start frame
	public function removeTween(aMask):void
	{
		aMask.removeEventListener(Event.ENTER_FRAME, tweenMe);
		aMask.hasFired = false;
	}
	
	public function checkFrame(evt):void
	{
		if(Parent.currentFrame < startFrame)
		{
			removeListeners();
		}
	}
	
	//remove all listeners
	public function removeListeners():void
	{
		hasFired = false;
		removeEventListener(Event.ENTER_FRAME, checkFrame);
		for(var i:int = 0; i < masks.length; i++)
		{
			var targetMask = masks*;
			targetMask.removeEventListener(Event.ENTER_FRAME, engageInit);
		}
		
	}
}

}