A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: Loading in arrays...

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Posts
    113

    Loading in arrays...

    Is it possible to load in an array?

    What I was thinking was having a variable like:

    myvar = john, fred, duke, dutchy

    And then some how putting it into an array. Is this possible or would I need a seperate variable for each name and then just put them in individually?

  2. #2
    Member
    Join Date
    Jul 2001
    Posts
    91
    you can have it be a string then use the split function to turn it into an array

  3. #3
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    Code:
    john = 5
    fred = "hello"
    duke = 10
    dutchy = "x"
    myvarsHoder = john + "," + fred + "," + duke + "," +dutchy;
    names = myvarsHoder.split(",")
    
    trace(names[0]);
    trace(names[1]);
    trace(names[2]);
    trace(names[3]);
    or make a string of it like:

    Code:
    myvar = "john|fred|duke|dutchy";
    names = myvar.split("|")
    trace(names[0]);
    trace(names[1]);
    trace(names[2]);
    trace(names[3]);

    hope this helped

  4. #4
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    Excellent. Thanks guys I worked it out thanks to you two =)

  5. #5
    free-webmaster-resource.com deamothul's Avatar
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    1,475
    no problem

  6. #6
    Member
    Join Date
    Aug 2001
    Posts
    41
    I'd like to thank you guys for this one as well.

    And a question: Is there an upper limit to variables loaded in before the number begins to affect performance?

    Again, thanks
    Karen

  7. #7
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Is there an upper limit to variables loaded in before the number begins to affect performance?
    Almost certainly, but I remember uploading several hundred rows of data into a database app I made in Flash 4 and I regularly load a coupla hundred K of XML into various projects I have in MX.
    In both cases, it worked fine.
    That should allow you to do some useful stuff.
    What slowed it down was getting too many MCs with too many onEnterFrames ...

  8. #8
    Member
    Join Date
    Aug 2001
    Posts
    41
    Thanks. I'm positive that XML is the real answer to the problem in building this piece (i.e. mapping values that match coordinates of temperature/dew point), however I don't really have time to stop press and get XML savvy... Need to do that at some point tho.

    However, I'm thinking that smart parsing of ranges of dew points only when needed and then further parsing of the exact user input for temperature may be the band aid. Just wondering how many levels I should set up for the hierarchy, and I'm thinking 30 could do it.

    i.e. User inputs 40 as the dew point and 50 as the temperature; the application will then translate those coordinates to carb-ice risk in an airplane.

    Again, thank you!!

  9. #9
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Er ... 30? THIRTY levels of hierarchy?

    NO NO NO NO NO NO NO NO NO!

    That way madness lies. Beware for there be demons and dragons and vicious wee beasties with pointy teeth.

    I don't know what you are doing, but if you are thinking of hard-coding a number of hierarchies OR going higher than three, you NEED to learn XML.

    It really is a cinch to do and it has the added advantage you can use recursive functions to handle any number of hierarchies.

    BTW, what ARE you doing?

  10. #10
    Member
    Join Date
    Aug 2001
    Posts
    41
    Yikes! No. I meant to say, and didn't say it well, is 30 variables holding the strings of further variables. Hierarchy would be 2 levels down:

    Level A = long strings of ranges, comma deliminated, with first numerals in each string identifying next level.

    Level B = actual strings of values, "|" deliminated, with first numerals significant to the actual data

    So, (still working this out, bear with me -the numbers are nonsense):

    RangeA = 16,48,16|1|16|yellow|46, ...{{{lots of other strings between 16 and 48}}} ... ,48|4|48|Red|62|Orange|79|Tan|86|Yellow|97 ... and so on

    If the user chooses 48, I'd have flash split Range A based on comma. It could then further parse based on actual dewpoint. Range A's myVar[0] would always indicate the lower bound and myVar[1] would always indicate the upper bound. The first numeral in each string of myVar after that would be the dewpoint selected... there's logic there.

    The whole point is trying to get away from loading in 90 strings of dewpoints for poor Flash to try to keep up with. Need a way to load in perhaps a third of that; maybe less.

    Trying to build a small feature in a website that will allow pilots to simply type in temperature and dewpoint and have the application indicate what the approximate risk of carbeurator icing is likely to be. You can pretty much figure it out in rough terms (hmmmm, relative humidity is 99% and it's 50 degrees today... I wonder if I should fly?... that's a joke), but in many cases the risk can surprise.

  11. #11
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    1. Learn XML before you start.
    2. Revisit point one.

    In XML, it might take 50 lines of code.

    Using text variables, it could take a lot more, be impossible to maintain and not work.

    This is because of the human involved. No issue with Flash handling hundreds of different variables, a major issue with you being able to work out what you have done.

    XML keeps it simple and you can refer to bits by name.

  12. #12
    Member
    Join Date
    Aug 2001
    Posts
    41
    I was afraid you were going to say that.

    I know you're right too. *sigh*

    My thanks,
    Karen

  13. #13
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    This is probably way off, but it might get you started.

  14. #14
    Member
    Join Date
    Aug 2001
    Posts
    41
    This is fantastic!! Thank you so much for doing this. You're correct; it gives me an excellent place to start.

    I do have a resource on XML in my library, and this project, with your help in the right direction, is a great way to get my feet wet.

    Again, my many thanks!
    -Karen

  15. #15
    Member
    Join Date
    Aug 2001
    Posts
    41
    Another quick note of gratitude is in order.

    After spending a few hours digging into the files you so kindly created for me, I've been able to build the logic for my application using XML.

    Your help was a godsend. And... I finally get it! At least, I understand enough to do this flash piece and also to begin exlporing XML in Flash a little further.

    I can't tell you how much this has helped me.

    -Karen

  16. #16

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