PDA

View Full Version : saving and loading variables


kilauea
07-30-2007, 06:51 AM
I need to setup a system where I can have people login (either seperately through a website, or directly through the .swf) play my flash movie and then periodically be able to save certain variables, then the next time they login those variables are loaded again for them.

I realize this will probably require a server-side script, and I have an apache http server setup to test this with on my LAN. The thing is I'm pretty bad with PHP and don't even know where to start. Can anyone give me some help?

[edit]
I have found a few tutorials that covered saving certain variables to a text file, but I can't quite relate that to what I need to do. I also can't find information on loading the variables again, and the variables weren't really stored in a retrievable manner anyway.

sneakyimp
07-31-2007, 12:46 AM
You've made the big leap which is to realize that Flash can't really save data.

The trick would be to connect Flash to a scripting language like ASP or PHP. There's a tutorial here for Actionscript 3:
http://www.flash-db.com/Tutorials/saving/

There's another post here at flashkit:
http://board.flashkit.com/board/showthread.php?t=737052

Here's a tutorial from adobe itself:
http://www.adobe.com/devnet/flash/articles/flashmx_php.html


The basic idea is that in Flash, you write actionscript to store your variables. When you want to send them to the server for saving, you put them in a LoadVars object or an XML object and then use sendAndLoad to communicate with your ASP/PHP page.

Your ASP/PHP page will then receive the variables and must decide what to do with them. ASP and PHP can either save the information into a text file somewhere or they can put them into a database (if there's a database server installed).

Try reading a bit of those tutorials. If you get confused, ask more specific questions.