A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Load variables from .txt into an array

  1. #1
    Junior Member
    Join Date
    Aug 2000
    Posts
    29
    I am trying to load a bunch of cosine^-1 values (0-360 degrees in 0.5 degree increments) into an array from a text file. I created a C++ program to output the values in a "cosine_value=angle&cosine_value=angle" format, but I don't know how to get Flash to read them directly into an array. I could have it load all the variables and then load them into an array using a loop, but I don't want 720 independant variables residing in memory on whatever computer this is going to be run on. I don't know how flash responds to that and it just seems sloppy to me.

    If you have any ideas let me know!

    Aaron
    (working on signature)

  2. #2
    The most effective way to go is to create and load a .swf file that acts as your trig library, or include its content directly in your movie and use it. Write these variables so that they are, in fact, naturally placed in an array:

    set variable sec0=1
    set variable sec1=1.00020004
    set variable sec2=1.00060036
    ...

    Do you really need the .5 degrees increments?

    Now, to specifically respond to your question, that is, how do i get rid of 720 variables after they are loaded into an array:
    Load them into a mc, initialize your array with their values, then either unload your mc, or load an empty movie to replace it. You could also advance your movie to an empty frame, de facto freeing your memory, but from my experience, these variables are not necessarily garbage-collected immediately.

  3. #3
    Junior Member
    Join Date
    Aug 2000
    Posts
    29

    Great idea

    Hey, thanks.

    That load/unload trig library sounds great. I could just create the whole thing, load what I want from it into an array in my real movie, then cut it out, unloading it from memory. Very clean and efficient while not limiting in any way. Exactly what I was looking for, thank you so much!

    Aaron

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