Changing Text with keystroke

FlashMX
Here is what I’m trying to do. I want to be able to have a dynamic text box that contains the titles for the photos in the photo gallery. The titles would be stored in a .txt file with variables such as title1, title2, etc. As the images change with the button click, so would the value of the variable for the text box.

I’ve been working on script pieces in different files.Here’s what I have:

This gets me an array that I can cycle through with keystrokes. This is on frame 1 of the actions layer.
[COLOR=orangered]
this.title_array=[title1,title2];
this.title_index=0;
title=this.title_array[this.title_index];
function ChangeTitle(d){
this.title_index=(this.title_index+d)%this.title_array.length;
if(this.title_index<0){
this.title_index += this.title_array.length;
}
title=this.title_array[this.title_index];
trace(title);
}
function onKeyDown(){
if(Key.getCode()==Key.LEFT){
this.ChangeTitle(-1);
}else if(Key.getCode()==Key.RIGHT){
this.ChangeTitle(1);
}
};
Key.addListener(this);
[/COLOR]
The next piece is a LoadVars piece that loads the variable from the text file. I have this on frame 1 on the LoadData layer.
[COLOR=orangered]
titleVars = new LoadVars();
titleVars.onload = addItems;
titleVars.load(“text.txt”);
[/COLOR]
I have this on frame 1 of the actions layer.
[COLOR=orangered]
function addItems(){
title1 = titleVars.title1;
title2 = titleVars.title2;
}
[/COLOR]
So, I have been trying to combine them but haven’t been having much luck.I just started working with actionscript about 5 days ago, so I’m sure there is probably a simple solution that I’m overlooking.

Thanks for the help