A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 58

Thread: [F8] Writing an array in a text file

  1. #21
    Member
    Join Date
    Aug 2007
    Posts
    87
    Thanks, you were a huge help. I may need more help from you later but it will probably be more complicated if you dont mind

  2. #22
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    Quote Originally Posted by dm2757
    Thanks, you were a huge help. I may need more help from you later but it will probably be more complicated if you dont mind
    No problem.

  3. #23
    Member
    Join Date
    Aug 2007
    Posts
    87
    Now that I have read that file into flash I now need to parse it out so that I can break down that file and redraw it in flash. Do you by chance understand that text file?

  4. #24
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    Quote Originally Posted by dm2757
    Now that I have read that file into flash I now need to parse it out so that I can break down that file and redraw it in flash. Do you by chance understand that text file?
    The text file looks like line coordinates if I’m not mistaken?
    The reason I think that is because of the last line in that txt file.
    (EndOfDWF)


    Let me know and I will see if I can help.

  5. #25
    Member
    Join Date
    Aug 2007
    Posts
    87
    Correct! I am writing a detail on all the lines of this file that may help you help me.

  6. #26
    Member
    Join Date
    Aug 2007
    Posts
    87

    Text file

    This whole file is a CAD file with just x,y coordinates.

    1st line is the file version.
    2nd and 3rd line is the view or the stage size.(2 points that make a rectangle)
    4th line is the background color.
    5th line is the object colors.(3 stands for green)
    6th line displays a square. P 5 tells you that their is 5 points and all the points are after that.
    The next set of points start at p 37 which is a circle.
    And the next set starts at p 4 which is a triangle.

    I just dont know how I am suppose to break this down in flash so that flash will read the coordinates for me. I have already manually put in all the coordinates which will be in the master file that I have included.
    Attached Files Attached Files

  7. #27
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    So what exactly are you wantting, are you wantting Flash to draw those coordinates? Are you just wantting to give details about each line?

    Fill me in a little on what you are wantting this to do.

  8. #28
    Member
    Join Date
    Aug 2007
    Posts
    87
    Yes on the 1st question. I want flash to plot the coordinates for me. I think I need to create an array and parse the array but I am not very sure. Also ontop of just reading in the coordinates I need to be able to scale them down as will because they are so large. I think if I divide all the coordinates by 1000 that would be better also. So I also need to create a scale function to go along with the rest.
    Last edited by dm2757; 08-23-2007 at 12:19 PM. Reason: forgot something

  9. #29
    Member
    Join Date
    Dec 2003
    Location
    Yukon, Oklahoma
    Posts
    44
    Quote Originally Posted by dm2757
    Yes on the 1st question. I want flash to plot the coordinates for me. I think I need to create an array and parse the array but I am not very sure.
    I see what your trying to do. This could be a very hairy script trying to get this. The only way I can thing about do this would be make each line its own var. such as:

    on P 37

    &cirleLine1=12587,58659&
    &cirleLine2=-13906,73739&
    &cirleLine3=-17822,88362&
    etc etc

    and then send that into flash but if you have somthing more elabrate than this it could get very hairy and time consuming fast. I'm sure there is a better way of doing this I just can't think of one at the moment. I'll think about it and get back with you.

  10. #30
    Member
    Join Date
    Aug 2007
    Posts
    87
    Yeah I know this is not going to be an easy process. The 1st thought you had, I had already pretty much done in the master file that I had sent you. Since I have already read the text file into flash so now it is in fla. format it will make it easier to read the coordinates but that still doesnt mean it is easy. I have never had to do anything like this before. So honestly I dont even know whre to start. I will continue to try to figure out how to write this script at the same time as you try. I really appreciate this.

  11. #31
    Member
    Join Date
    Aug 2007
    Posts
    87

    Parsed data

    Have you figured anything out yet? I have kinda been working on it and throwing a few things together and flash is trying to pick apart the data but not really. the files I am including are the txt file, the text fla file and the square fla file is the one I am working on to parse the data.
    Attached Files Attached Files

  12. #32
    Member
    Join Date
    Aug 2007
    Posts
    87
    This is what I came up with. I figured out that in order for this to work I have got to break up the text file into individual elements. I need to create an array and parse out each individual element. Does that sound about right to you?

  13. #33
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Errr...I didn't read this whole thread, only this last page, but is your goal to make a text file, then Flash uses that file to draw lines in Flash? Well, I think that you should use XML. You'd have a bit of learning to do, though actually, I'm not gonna say "There's some really good tutorials on Flashkit!". Well, for each time I asked to learn XML, someone said that, which made me mad since I hate sifting through those thousands of tutorials.

    Just E-mail me, and then when I get back I'll make an example and e-mail you it back.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  14. #34
    Member
    Join Date
    Aug 2007
    Posts
    87

    Arrays

    I have included a txt file that I am having to put into arrays. Do I have to rewrite this file in order for script to be able to read it?
    Attached Files Attached Files

  15. #35
    Member
    Join Date
    Aug 2007
    Posts
    87

    [F8] Writing an array in a text file

    I have this file that has 3 shapes in it and they are separated by the P's and # next to it. I cant just create an array script in flash to read this file so I need to rewrite it. I guess what the question is how would you create this file in a list style format that flash can read? The file is nothing but x,y coordinates. I need to create and array that will be able to be drawn in flash.
    Attached Files Attached Files
    Last edited by dm2757; 08-24-2007 at 05:36 PM. Reason: more detail

  16. #36
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    lv = new LoadVars();
    lv.load("test.txt"); 

    lv.onLoad = function(){
    str unescape(this);
    str str.split("\r\n").join("");
    str str.split("=&onLoad=[type Function]").join("");
    arr str.split("@@@");
    for(var 
    i=0;i<arr.length;i++){
    arr[i] = arr[i].split("**");
    trace('arr['+i+'][0] --'+arr[i][0]);
    arr[i][1] = arr[i][1].split("##");
    len arr[i][1].length;
    for(var 
    ii=0;ii<len;ii++){
    arr[i][1][ii] = arr[i][1][ii].split(",");
    len2 arr[i][1][ii].length;
    for(var 
    j=0;j<len2;j++){
    trace('arr['+i+'][1]['+ii+']['+j+'] -- '+arr[i][1][ii][j]);
    }
    }
    }
    };

    /*--add delimiters to the text format and use 
    each one to split to a multi-dimensional array -

    @@@ - P separator
    ## - end of each line of numbers
    comma - separator between numbers

    in test.txt -

    P 5**0,0 0,122880 122880,122880 122880,0##
    0,0##@@@
    P 37**-12587,58659 -13906,73739 -17822,88362 -24217,102083##
    -32896,114486 -43596,125195 -55992,133884 -69708,140289##
    -84328,144217 -99407,145547 -114488,144241 -129114,140336##
    -142840,133953 -155250,125284 -165967,114592 -174666,102203##
    -181082,88492 -185022,73875 -186364,58797 -185070,43715##
    -181177,29086 -174804,15355 -166145,2938 -155462,-7788##
    -143080,-16496 -129374,-22924 -114760,-26875 -99683,-28229##
    -84600,-26947 -69968,-23065 -56232,-16704 -43808,-8054##
    -33074,2620 -24356,14995 -17917,28696 -13955,43306##
    -12588,58383##@@@
    P 4**142892,-6950 204332,115930 265772,-6950 142892,-6950

    */ 

  17. #37
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    See if this helps.

    Notice that this example is very simple and is for very simple situations.
    If you need a more control over what you're loading, and the data itself, you should consider using XML.

    XML, unlike a text file, can be very descriptive and can offer a strong structure for the data.

  18. #38
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    @dm2757:
    you are officially now on my ignore list,- this is propably your 7th or 8th new post post regarding the same matter - each post comes only with a little text and without any direction
    People like you are wasting valueable resources here

  19. #39
    Member
    Join Date
    Aug 2007
    Posts
    87

    error

    When I changed the structure of the text file to be read by Flash I got a massive error message. I am including the text file and the fla file. But this is the error msg I keep getting. What is this error telling me?
    arr[0][0] --P 5
    arr[0][1][0][0] -- 0
    arr[0][1][0][1] -- 0 0
    arr[0][1][0][2] -- 123 123
    arr[0][1][0][3] -- 123 123
    arr[0][1][0][4] -- 0
    arr[0][1][1][0] -- 0
    arr[0][1][1][1] -- 0
    arr[0][1][2][0] --
    arr[1][0] -- P 37
    arr[1][1][0][0] -- -13
    arr[1][1][0][1] -- 59 -14
    arr[1][1][0][2] -- 74 -18
    arr[1][1][0][3] -- 88 -24
    arr[1][1][0][4] -- 102
    arr[1][1][1][0] -- -33
    arr[1][1][1][1] -- 114 -44
    arr[1][1][1][2] -- 125 -56
    arr[1][1][1][3] -- 134 -70
    arr[1][1][1][4] -- 140
    arr[1][1][2][0] -- -84
    arr[1][1][2][1] -- 144 -99
    arr[1][1][2][2] -- 146 -114
    arr[1][1][2][3] -- 144 -129
    arr[1][1][2][4] -- 140
    arr[1][1][3][0] -- -143
    arr[1][1][3][1] -- 134 -155
    arr[1][1][3][2] -- 125 -166
    arr[1][1][3][3] -- 115 -175
    arr[1][1][3][4] -- 102
    arr[1][1][4][0] -- -181
    arr[1][1][4][1] -- 88 -185
    arr[1][1][4][2] -- 74 -186
    arr[1][1][4][3] -- 59 -185
    arr[1][1][4][4] -- 44
    arr[1][1][5][0] -- -184
    arr[1][1][5][1] -- 29 -175
    arr[1][1][5][2] -- 15 -166
    arr[1][1][5][3] -- 3 -155
    arr[1][1][5][4] -- -8
    arr[1][1][6][0] -- -143
    arr[1][1][6][1] -- -16 -129
    arr[1][1][6][2] -- -23 -115
    arr[1][1][6][3] -- -27 -100
    arr[1][1][6][4] -- -28
    arr[1][1][7][0] -- -85
    arr[1][1][7][1] -- -27 -70
    arr[1][1][7][2] -- -23 -56
    arr[1][1][7][3] -- -17 -44
    arr[1][1][7][4] -- -8
    arr[1][1][8][0] -- -33
    arr[1][1][8][1] -- 3 -24
    arr[1][1][8][2] -- 15 -18
    arr[1][1][8][3] -- 29 -14
    arr[1][1][8][4] -- 43
    arr[1][1][9][0] -- -13
    arr[1][1][9][1] -- 58
    arr[1][1][10][0] --
    arr[2][0] -- P 4
    arr[2][1][0][0] -- 143
    arr[2][1][0][1] -- -7 204
    arr[2][1][0][2] -- 116 266
    arr[2][1][0][3] -- -7 143
    arr[2][1][0][4] -- -7 */
    Attached Files Attached Files
    Last edited by dm2757; 08-27-2007 at 10:16 AM.

  20. #40
    Member
    Join Date
    Aug 2007
    Posts
    87

    Rewritten Text file

    Can you take a look at this text file, I rewrote in a different format that was easire for me. How do I use script to display the shapes in this file in Flash 8? I appreciate any help that I can get.
    Attached Files Attached Files

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