Count lines in .txt file and addChilds with scrolling
Copy link to clipboard
Copied
Hello everyone, and good day. I have question. I know how to load information from external txt file. But i need to do this:
I have *.txt file for example:
2018 - 05 - 24 - 14:30 from..
2018 - 05 - 25 - 14:30 from..
2018 - 05 - 26 - 14:30 from..
2018 - 06 - 01 - 14:30 from..
2018 - 06 - 24 - 14:30 from..
2018 - 12 - 24 - 14:30 from..
2018 - 12 - 24 - 14:30 from..
I need that flash count how many lines are in txt file, in this case 7 so i need to add 7 childs and fill textfields with information to every child. So i need 7 childs with different information in text fields from txt file. But in screen i want to see just 4 and others i want to see just when i scroll. Maby have some ideas how can i do that?
And i iff i add new line flash detects that and add another one child, if i delete line flash detects that and delete child.
?
Maby someone can help with this?
Copy link to clipboard
Copied
use the data raw from URLloader, split("\n")
the use a for loop
Copy link to clipboard
Copied
I use split('/n");
but how i tell him to count all line and i get one child with information from line.
but i need to count all lines
add in this case 7 childs with different information
Copy link to clipboard
Copied
your dataResult.length count all lines.
then if the for loop just add your conditions to find the right line
Copy link to clipboard
Copied
var dataLoader: URLLoader = new URLLoader();
var dataArray: Array = new Array();
var timeArray: Array = new Array();
dataLoader.load(new URLRequest("test.txt"));
dataLoader.addEventListener(Event.COMPLETE, dataLoaded);
function dataLoaded(event: Event): void {
dataLoader.removeEventListener(Event.COMPLETE, dataLoaded);
dataArray = event.target.data.split("\n");
show_time();
}
var ix:Number = 0;
var iy:Number = 0;
var a:Number = 0;
function show_time(){
var i:int;
for (i = 0; i < dataArray.length; i++){
trace("yes");
var kalendorius:MovieClip = new calendar;
kalendorius.name = "data"+i;
stage.addChild(kalendorius);
kalendorius.x = ix;
kalendorius.y = iy;
timeArray = dataArray.split(" - ");
kalendorius.menuo.text = timeArray[0];
kalendorius.diena.text = timeArray[1];
kalendorius.savaites_diena.text = timeArray[2];
kalendorius.time1.text = timeArray[3];
kalendorius.time2.text = timeArray[4];
kalendorius.patvirtinimas.text = timeArray[5];
a++;
iy=iy+335;
}
}
THIS IS MY CODE. IT WORKS GOOD FOR ME. I dont know if it is right, but it works.
Now question is how to do this with scrooling becouse if i have 10 lines i have 10 childs but i want to see just 4 and others with scroling
Copy link to clipboard
Copied
can someone help with scroll
?:(
Copy link to clipboard
Copied
have the same need but I'm not sure there is a way to hack the component

