A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: saving and loading via ByteArray = complex search and finding

  1. #1
    Junior Member
    Join Date
    Sep 2017
    Posts
    14

    saving and loading via ByteArray = complex search and finding

    Okay, a bit odd in a way but probably really easy if I can remember some of this..

    I mostly used Shared objects for basic load/save functions because it's pretty easy and you can just dump a bunch of arrays and load them again with little problem, mostly just call the reference to the array name and where to load it to.

    However, I want to use a better system since Shared objects (Cookies) are soo disposable and all, that it's not a great way to store a saved game or the like. Problem is, what I know of Byte Arrays doesn't quite cover how to do this. I know how to dump a stuff into a bytearray and how to load it, but as I know it, it loads as one 'lump'. or with byte offsets.. and I'm not sure if I can save at set bytes as 'names' for arrays and load easily like this or not.. anyone sure?

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,835
    Cookies are the only native actionscript way to save data. Otherwise you need to set up a way to have the website save data. The only exception to this is Adobe Air. Otherwise you need a script like php to actually perform the filesave. You shouldn't need bytearray at all unless security's involved. I'm pretty sure https://help.adobe.com/en_US/FlashPl...Reference.html is what is normally used to save files. I might be mistaken but I think it requires the AIR platform.

    I'm not completely certain I'm correct but this should give you a direction.
    .

  3. #3
    Junior Member
    Join Date
    Sep 2017
    Posts
    14
    thanks, decided I could apply the arrays to an object, and dump that via ByteArray and filestream. slight problem but.. if due to various reasons (not always the best to say about) an array happens to have a link/whatever as a timer or anything, when it loads, it's just 'object' and will lead to errors.. I'm looking into dealing with that bit.

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,835
    One option you could look at is making your own function to deconstruct/construct objects to/from a bytearray. You'd have to construct it to be able to handle each data type specifically. Using https://stackoverflow.com/questions/...rvar-s-in-this to catch the contents of the object. Then use a switch statement to handle the data types when constructing the array. In the array you'd want to start with an identifier for the type and length of each variable in the bytearray.
    .

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    tempy ill give you a good clean shared object script that constructs/deconstructs for many variables to use if you send me $1 to my paypal email.

    data types like this can be saved within square brackets [1,0][5,1][2,4]

    paypal: crystalskate@gmail.com
    Last edited by AS3.0; 06-30-2019 at 08:00 PM.

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