all groups > flash actionscript > july 2007 >
You're in the

flash actionscript

group:

Importing Text File data



Importing Text File data kal1000
7/21/2007 11:00:00 PM
flash actionscript: At the moment I know how to enter data from a text file into a flash file, for
example this is my 'monday.txt' file (a cut down version)

"AK2~Hairdressing Level 2 Year 2 Of 2","HDRN2AK2-2B1FA","12:30","14:30"," 10/
9/2007","M316"
"AK2~Hairdressing NVQ L2 (Grp A)","HDRN2AK2-1B1FA","12:30","14:30"," 10/
9/2007","M316"
"AK2~Hairdressing NVQ L2 (Grp B)","HDRN2AK2-1B1FB","12:30","14:30"," 10/
9/2007","M308"
"Beauty Therapy Level 1 Grp D","BTHN1-1B1FD","9:00","10:30"," 10/
9/2007","M306"
"Beauty Therapy NVQ Level 1 Grp A","BTHN1-1B1FA","9:00","10:30"," 10/
9/2007","M306"
"Beauty Therapy NVQ Level 1 Grp B","BTHN1-1B1FB","9:00","10:30"," 10/
9/2007","M306"
"Beauty Therapy NVQ Level 1 Grp C","BTHN1-1B1FC","9:00","10:30"," 10/
9/2007","M306"
"Beauty Therapy NVQ Level 2 Grp A","BTHN2-1B1FA","9:00","12:00"," 10/
9/2007","M217"
"Beauty Therapy NVQ Level 2 Grp A","BTHN2-1B1FA","12:30","14:00"," 10/
9/2007","M306"
"Beauty Therapy NVQ Level 2 Grp D","BTHN2-1B1FD","12:00","15:00"," 10/
9/2007","M217"

Using this coding, I now know how to get it into columns in a tabbed layout

var lv:LoadVars = new LoadVars();
lv.onLoad = func;
lv.load("Monday.txt");

function func(ok) {
if (!ok) {
trace("file not loaded.");
return;
}
var tf:TextFormat = new TextFormat();
tf.tabStops = [220, 340, 390, 440, 490, 520];
tf.font = "Verdana";
tf.size = 9;
var nextD:Number = _root.getNextHighestDepth();
var w:Number = Stage.width - 20;
var h:Number = Stage.height - 20;
var txt:TextField = _root.createTextField("schedule", nextD, 10, 10, w, h);
txt.wordWrap = txt.multiline = /*txt.border =*/ true;
txt.autoSize = true;
txt.setNewTextFormat(tf);
var temp1:Array = unescape(this).split("=&onLoad")[0].split("\n");
for (var i:Number = 0; i < temp1.length; i++) {
var temp2:String = temp1[i].split(",").join("\t").split("\"").join("");
txt.text = (txt.text.length > 0 ? txt.text : "") + temp2 + (i ==
temp1.length-1 ? " " : " \n");
}
}

The problem I have now is, in the text file I am going to have upto 120-130 of
these records, now the maximum I can fit onto the screen is 20, is there a way
I can split this text file up so I can show Page 1/7, 2/7, 3/7, 4/7, 5/7, 6/7
and 7/7, where it switches over automatically via a timer of some sort, say
after 20 seconds.
Re: Importing Text File data kglad
7/22/2007 4:29:06 AM
sure. there are many ways to do this.

one would be to use one textfield and load all your text into it. use a timer
like setInterval() to periodically increase the scroll property of your
textfield by its bottomScroll property.

you'll need to fill your last page with carriage returns or new lines so the
last page can scroll to the top of your textfield.
AddThis Social Bookmark Button