Saving data from AS3 to database.. what is the best method?
-
11-02-2021 - |
سؤال
I'm developing a two player turnbased game with flash, and i need to save data to database.
At the moment i am using AMFPHP. Works great.
Problem is i'm starting to have quite much information - different kind little things like x, y, hp, path, activeskills... etc. Every time i add something i have to code it to AS and PHP and modify DB structure.
So is there better solution to do this?
I would love to send AMF packet from flash to PHP and save it to DB. Other player could just load this AMF packet from DB ..but i guess that is not possible. Couldnt find any working solution from web.
**Ideal DB structure for me would be:
id,gameId,gameData
So how should i "compress" all data to 'gameData'?** Array, amf, string..
المحلول
- You could save a binary file to the SQL DB. For example, MySQL has a field type of BLOB to hold your data Object. I just can't remember if the data Objects get serialized automatically when transmitted via AMFPHP or will you have to do some serialization.
- You could encode the data Object via Base64 and save it to the SQL DB.
- The most elegant way I can think for solving this problem is to write the gameData as a JSON formatted string.
نصائح أخرى
AMF isn't the issue: the truth is that you haven't yet completed your app and you're seeking to use a shortcut that negates much of the benefit that AMF provides (e.g. strong typing).
You need to finalise the parameters you need to exchange / save, normalise the storage of that data and update your AMF classes accordingly.