What's the easiest way to store a simple numeric variable on my server and then have a Flash application also hosted on the server read/write the variable?
I've seen various xml solutions, but they look too complex for such a simple job. Is there a way to just read/write a simple text file with just AS开发者_StackOverflow社区3 and no middle-ware?
The easiest is to use remote shared objects. There's a number of server solutions that supoort this. To my knowledge AMFPHP and WebORB, BlazeDS and ColdFusion. And there probably is a ton of other implementations, other than the costy flash media server.
However, it seems your idea of the web is a little naive. To just "read" a file, there must be a service running on the host exposing it via some protocoll. Writing is the same thing. Some day, you'll also find out, you have many users, thus you need to handle conflicts, race condictions etc. and you'd like to be able to have some access control with user groups and all that.
There is no trivial solution you could possibly be happy with for a mentionable timespan, only such solutions, that look simple from the outside. Even a lot of them. Choosing is a matter of personal taste and what your serverside platform is.
greetz
back2dos
You can read a text file but not write. You'll need some server-side application to write.
Easiest way to read is with flash.net.URLLoader
which can create flash variables from URL-encoded text. This class can also post url-encoded data to a server side handler which can write to disk.
If you don't need to share the values across users then another option is a local SharedObject
which is a lot like a cookie but much more efficient (never sends data to server, can store more data, stores type data).
精彩评论