Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Count lines in .txt file and addChilds with scrolling

Explorer ,
Apr 11, 2018 Apr 11, 2018

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?

TOPICS
ActionScript
397
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 11, 2018 Apr 11, 2018

use the data raw from URLloader, split("\n")

the use a for loop

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2018 Apr 11, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 11, 2018 Apr 11, 2018

your dataResult.length count all lines.

then if the for loop just add your conditions to find the right line

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2018 Apr 12, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 12, 2018 Apr 12, 2018

can someone help with scroll

?:(

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 12, 2018 Apr 12, 2018
LATEST

have the same need but I'm not sure there is a way to hack the component

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines