A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: capture external file variables into an array?

  1. #1
    Member
    Join Date
    Feb 2001
    Posts
    44

    resolved

    Hi guys,

    The problem elements are like this

    a)I have a text file that contains strings.each string has special characters($)that will come into play later

    eg var1=/"this is a string.$mayavi$2001/"&var2=...etc..
    &datacomplete=yes
    I need to

    a)capture these variables in an array say new primary();
    b)detect the end of data in file.
    c)split this primary array elements along the special characters and populate secondary arrays.

    eg primary[0]="this is a string.$mayavi$2001" ;
    text[0]="this is a string";
    author[0]="mayavi";
    year[0]="2001";


    can some kind soul help another in distress.

    thanx guys










  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    44

    resolved come on guys I m desperate

    somebody please help. I am desperate on this .

    thanx,
    mayavi

  3. #3
    Member
    Join Date
    Feb 2001
    Posts
    44

    resolved no help?

    hey guys no help?...

  4. #4
    proud new daddy! LuxFX's Avatar
    Join Date
    May 2000
    Location
    Dunsinane
    Posts
    1,148
    Well, for starters it looks like you need to use the split() function. Look at this code:

    primary[0]="this is a string.$mayavi$2001" ;
    splitPrimary = new Array();
    splitPrimary = primary[0].split("$");

    And then you have an array, splitPrimary, that has three values, [0] is "this is a string.", [1] is "mayavi", and [2] is "2001". You could then just write more code to assign these values to your other arrays.

    hope this helps!

  5. #5
    Member
    Join Date
    Feb 2001
    Posts
    44

    resolved thanx fx

    Thanx LuxFx it works great now, but still having problems capturing the external variables into arrays.
    Do u have any pointers in that direction?

    cheers,
    mayavi

  6. #6
    proud new daddy! LuxFX's Avatar
    Join Date
    May 2000
    Location
    Dunsinane
    Posts
    1,148
    Whenever I pull in an external variable to be used as an array, I format it like this in the text file:

    arrayString=var1|var2|var3|var4|var5

    And in Flash, after this imported, I use the split() function to turn it into a real array, like this:

    myArray = arrayString.split("|");

    The trick is to use a character that is hardly ever used anywhere else, so I use the pipe. You might have had problems using a '$'.

    Is this going to help?

  7. #7
    Member
    Join Date
    Feb 2001
    Posts
    44

    resolved hey it helps

    thanx a lot i does work luxfx..

    cheers,
    mayavi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center