Scrolling Text - [Function Question]

Hi, I have a couple of questions about this function which loads an external text file into flash and scrolls.

Currently, when I have a link in the text file, I wrap the text in an “a href” tag and then use the “u” tag to underline the link and I also specify the target in each individual link. I was wondering if there is a way to accomplish the underlining of links, and the target specification from this AS?

Also, I reuse this code for 3 different pieces of news that are all pulled from the same text file. Currently I simply change the “ts” value and the “ts.theText.theTextBox.htmlText” value for each one. Obviously this is a very inefficient method to use so i’m looking for some help with this. Thanks.


init();
// ----------------------------------------------------------------------------
function init() {
	// Create a persistent reference to the textScroller clip
	ts = _root.hpTextScroller.textScroller;

	// Initialise some positions
	textBwidth = 145;
	textBheight = 200;
	ts.theMask._height = 200;
	
	// Create text field
	drawTextBox();
}
// ----------------------------------------------------------------------------
function drawTextBox() {
	// Create the text field in 'theText' movie clip
	ts.theText.createTextField("theTextBox", 1, 0, 0, textBwidth, textBheight);
	ts.theText.theTextBox.html = true;
	ts.theText.theTextBox.textColor = "0x000000";
	ts.theText.theTextBox.selectable = false;
	ts.theText.theTextBox.wordWrap = true;
	myTextFormat = new TextFormat();
	myTextFormat.font = "Standard";
	myTextFormat.size = 8;
	myTextFormat.leading = 2;
	ts.theText.theTextBox.embedFonts = true;
	
	// Load external text file
	loadText();
}
// ----------------------------------------------------------------------------
function loadText() {
	// Make sure external text file is loaded
	loadData = new LoadVars();
	loadData.load("news.txt");
	loadData.onLoad = function(success) {
		if (success) {
			trace("done loading");
			ts.theText.theTextBox.htmlText = loadData.theText;
			ts.theText.theTextBox.setTextFormat(myTextFormat);
			ts.theText.theTextBox.autosize ="center";
			// Set mask and dragger parameters
			setParam();
			} else {
			trace("failed");
			}
		}
}
// ----------------------------------------------------------------------------
function setParam() {
	// Mask and dragger parameters
	ts.theMask._width = textBwidth+2;
	ts.theMask._x = 0;
	ts.theMask._y = 0;
	ts.dragger._x = 146;
	ts.dragger._y = 0;
	ts.theText._x = 0;
	ts.theText._y = 0;

	// Set a variable
	targY = 0;
	
	// Set dragger scroll and mask
	setDragMask();
}
// ----------------------------------------------------------------------------
function setDragMask() {
	/* 
	Set the drag action of the dragger
	Drag is restricted to the height of the mask
	*/
	ts.dragger.onPress = function() {
		this.released = false;
		startDrag(this, false, this._x, 0, this._x, ts.theMask._height-this._height);
		// The scrolling animation
	    ts.theText.y = ts.theText._y;
		ts.theText.onEnterFrame = function() {
			trace("enterframe");
			/* 
			Set a variable this variable basically stores info regarding what fraction of 
			the total text is being displayed through the mask and ensures that dragging 
			the dragger from top to bottom will reveal all the text. this allows you to change 
			the amount of text and the scroller will update itself
			*/
			scrollAmount = (this._height - (ts.theMask._height/1.3))/(ts.theMask._height - ts.dragger._height);
			// Adjust the height of the dragger to reflect the amount of content available to see
			ts.dragger._height = 30;
			// Set a new target y position
			targY = -ts.dragger._y*scrollAmount;
			/* 
			Set the y of the text to 1/5 of the distance between its current y and the target y
			Change the 5 to a lower number for faster scrolling or a higher number for slower scrolling
			Math.round() keeps it on a whole pixel number - good for pixel fonts
			*/
			this.y -= (this.y-targY)/5;
			this._y = Math.round(this.y);
			trace(Math.abs(this._y)+' = '+Math.abs(targY));
			trace(Math.abs(this._y)+'<='+Math.abs(targY+1)+'&&'+Math.abs(this._y)+'>='+Math.abs(targY-1));
			if ( (Math.abs(this._y)<=Math.abs(targY)+1)&&(Math.abs(this._y)>=Math.abs(targY)-1)) {
				trace('inside');
				if(ts.dragger.released == true) {
					trace('delete');
					delete this.onEnterFrame;
				}
			}
		}
	}

	// Stop the drag
	ts.dragger.onRelease = ts.dragger.onReleaseOutside = function () {
		stopDrag();
		this.released = true;
	}

	// Set the mask for the text
	ts.theText.setMask(ts.theMask);
}