A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: can i load it from a text file??

  1. #1
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495

    can i load it from a text file??

    hi guys,

    i have an array called picdata[x]

    it contains 3 rows of data

    each row contains 5 pieces of information.

    is it possible for me to load this data from an external text file?

    (i eventually want lots of rows containing about 10 items each and the text file seems the easiest way to edit it0

    thanx in advance

    Gary

  2. #2
    Former Employee of Satan Napalm's Avatar
    Join Date
    May 2000
    Location
    Stellenbosch, South Africa
    Posts
    561
    Your textfile will look like this:

    whatever=Row1,1data,2data,3data,4data,5data;Row2,d ata,data,data,data,data;Row3,data,data,data,data,d ata;Row4,data,data,data,data,data;Row5,data,data,d ata,data,data

    Then in Flash you do the following;

    myArray = newArray();
    myArray = whatever.split(";");

    for(i=0; i<myArray.length; i++) {
    myArray[i] = myArray[i].split(",");
    }

    Use your debugger when you publish - that should help you a great deal
    Never underestimate the power of stupid people in large groups

  3. #3
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495
    hi napalm,

    thanx for the info but i found "#include"

    it is way simpler (i dont have to know the array length in advance as you have shown using the myarray.length.)

    but thanx for the input i was beginning to despair of anyone knowing what to do let alone how lol

    what i have now is a file called picdata.as (just a text file) and where i need to "fill" my array i just inserted #include "picdata.as" and it all works so smoothly.

    wanna increase the array just add a line in the text file upload it and my little gallery (it's a catalogue really) works fine

    again i cant say thanx enough, wish i knew all this stuff instead of struggling along from one "wont work" to the next lol (if i could do that i would prob do it as a job eh!)

    still i always feel i learn it better if i had to struggle to make things happen how i want them to


    cheers

    gary

  4. #4
    Junior Member
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    5
    Wouldn't using the #include remove some dynamicism from the fla by having to republish/export each time the input values of the array change?
    I'm lost and have gone looking for myself. If I should return before I get back, please ask me to wait.

  5. #5
    ask me one on fish..not flash
    Join Date
    Oct 2002
    Location
    southern u.k.
    Posts
    495
    didnt seem to matter when i tried it,
    i simply changed the text file and double-clicked on the existing swf. and there were my changes.

    i never thought about republishing it first. i assumed that each time the swf is started, the action script gets to the #include statement and rereads the file (like i tell it too) and does just what it tells it to.

    at least thats what appears to happen

    (just gotta sort out how to search through the thing now lolol....always something else to do eh!

    cheers for the interest anyways

    Gary_trying to search_bydesign

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