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

trace from external file

New Here ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

Hi everybody,

I am working on a project and I am using "trace()" to check the values that I load from an external file, in my case a csv file.

my code which fails is  the following:

trace(n1.text =  loadedData[0][0]);

trace(n2.text =  loadedData[1][0]);

trace(n3.text =  loadedData[2][0]);

trace(n4.text =  loadedData[3][0]);

trace(n5.text =  loadedData[4][0]);

trace(n6.text =  loadedData[5][0]);

trace(n7.text =  loadedData[6][0]);

trace(n8.text =  loadedData[7][0]);

if

(n1.text ==  loadedData[0][0])

{

(n1.text =  loadedData[0][0]);

(s1.text =  loadedData[0][1]);

(t1.text =  loadedData[0][2]);

(c1.text =  loadedData[0][3]);

}

else if

(n1.text == "")

{

gotoAndStop(6)

}

The problem is that I need to prepare a template with 8 text fields but the csv file that I load sometimes has 6 7 or 8 lines.

So when I trace 8 lines from my csv and there are less than 8 it doesn't work.

any suggestions?

Views

337

Translate

Translate

Report

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
LEGEND ,
Aug 16, 2019 Aug 16, 2019

Copy link to clipboard

Copied

Why in god's name are you performing assignment within your trace statements? Trace statements should never, ever contain essential code.

And why aren't you just using a loop instead of hard-coding eight trace statements?

Votes

Translate

Translate

Report

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
New Here ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

Hi ClayUUID

I know it sounds stupid and probably  it is, as well as it is wrong, but it didn't work when I just traced the loadingData alone.

as it concerns the loop you suggested I don't know how to use it so I write everything by hand. I will give it a try though.

Still if you have any suggestions concerning my real problem I will be thankfull.

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

it's not clear which you're using both loadedData[0] and loadedData[0], but this is one way to use a loop for one of those situations:

var i:int=0;

while(loadedData[0].length>0){

this['n'+(i+1)].text = loadedData[0];

trace(loadedData[0];

i++;

// you might want a break.  i can't tell

}

Votes

Translate

Translate

Report

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
New Here ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

Hi kglad,

thanks for the answer, obviously I didn't make myself or the problem clear.

I have 8 rows with some text fields and 8 image loaders. In the first frame lets call it first page, I load all the data I need so everything is ok.

Then I go to another frame and try to load different data on the same dynamic textfields and imageloaders, lets call this frame second page,My problem is that sometimes the second page contains less data than I need to fill all 8 rows. Bellow you will find a link with the fla, perharps it will more clear to you.

thanks in advamce

https://drive.google.com/drive/folders/1o-WFx__KYwYCivtiCp1OVwKr7QAKRnAP?usp=sharing

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 18, 2019 Aug 18, 2019

Copy link to clipboard

Copied

i don't usually download and correct files unless hired.

if you explain clearly, you can get free help here.  but if you're in a rush and don't mind paying, send me a private message.

Votes

Translate

Translate

Report

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
New Here ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

Hi kglad and thanks,

I uploaded the file just to help you get the better picture. I am not in rush, I can solve my problem by tracing my data in my UI software.
The whole post was just for educating reasons, because I thought that other beginners like me will face the same problem.

I will state again the problem,a shorter version  and I hope this time to be more clear....

I have 8 imageloaders, when I load from my csv 8 data everything is OK, when I load 7 or less it has an error.

The whole tracing issue I stated above was my try to let the fla know how many data will find.

Votes

Translate

Translate

Report

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
Community Expert ,
Aug 19, 2019 Aug 19, 2019

Copy link to clipboard

Copied

LATEST

what's the error and what line of code is triggering the error?

Votes

Translate

Translate

Report

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