A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Set an array to a cookie ?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Set an array to a cookie ?

    I dont know much about creating cookies and retrieving inforation and var's from cookies. So i was just wondering if its possible to set an entire array to a cookie.

    eg

    Code:
    myArray = [["James","Daniel","Jeff"],
               ["Kate","Shelly","Sarah"],
               ["Jessica","John","Sally"]];
    How would i do this and can i do this.

    And how do i retrieve the array and place the array in my actionscript.
    Im trying to create a save functoin that saves certian arrays and varibles to one cookie and then when the user starts the swf agian it reconises that the user has been on before and loads the array and the other var's to the swf.

    If i cant do this i dont know what i can do

    I think i saw a tut somewhere a while back but i forgot where.

    ThankS in AdvancE

    [h]ooligan

  2. #2
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Anyone , please help this is fairly urgent!

  3. #3
    Cats Moo!
    Join Date
    May 2000
    Location
    Boonies
    Posts
    148
    You are right about seeing a tutorial about saving and reloading at a later date. But if I remember correctly it is not through cookies... I think it is by saving a .swf file with the varibles to the users computer. I will try and find were this tut was...
    Sorry this didn't help much I'll try to be quick with a search...
    Christopher Michael

  4. #4
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks heaps ChriSell. That would be great.

    I have seen them do this through setcookie and retireve cookie too. But dont know how it works.
    Last edited by hooligan2001; 04-25-2003 at 01:20 AM.

  5. #5
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    you might wanna try this before you save it to a cookie;
    Code:
    myArray = [["James","Daniel","Jeff"],
               ["Kate","Shelly","Sarah"],
               ["Jessica","John","Sally"]];
    myString = myArray.toString();
    and this after you load it from a cookie;
    Code:
    myArray = myString.split(",");
    now there are a couple of caveats to this;
    1. you strings cannot contain a comma (i think)
    2. when the loaded string is split it will split it into a one dimensional array not a two dimensional array so you might have to add some code to convert it.
    ------------------------------------------------------------
    of course if your using mx then you could do it much easier using shared objects;
    http://www.koyote.dk/index.php?sid=36
    courtesy of the learned edmack
    hope this helps
    BlinkOk
    Last edited by BlinkOk; 04-25-2003 at 01:58 AM.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  6. #6
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks Heaps blink that will be a big help. Another quicky. How do i change a a heap of one dimensional arrays into a 2d array ?

    Do i just add each 1d array as a sibling to the 2d array ?

  7. #7
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    i would say that's the way to go; however you should know that unless you assign each indivual element of the array then you are assigning pointers and when you change a value in the new array you will be changing a value in the old arrays as well.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  8. #8
    uhm
    Join Date
    Nov 2000
    Location
    Leeds(ish), UK
    Posts
    99
    There's no need to do that. The attached fla will store a 2D array and retrieve it as a 2D array using sharedObjects.
    The prototype code is by flashguru (as far as I can remember).

    Enjoy!
    Attached Files Attached Files

  9. #9
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks BlinkOk.

    Thank you too voodoo-wizard. I cant seem to download the file atm dunno why. But ill try agian later.

    Thanks agian

  10. #10
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Finally got it. Thanks heaps for the fla voodoo-wizard works great

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