i am currently working on a facebook game and i have a problem concerning the integration of a life counter which regenerates over time for a facebook game.
The game is a simple Flash/AS3 shooter in which users are competing for the highest score.
For monetary reasons every game costs one life and users should only be able to start a new game, if said life counter is >=1.
To clear things up, i submitted a link to Popcap’s facebook game “Zuma Blitz”:
I can think of a few ways to do this, but i don’t know which is the best/easiest approach.
Would it be best to:
-
Make it in AS3 with server communication via php?
-
Or do it in JavaScript and communicate the count back to AS3?
Another maybe related question is, how do i tell my database that the data from the life counter should be stored when the game is closed (for example by closing the browser).
Can i do this from Flash or do i have to apply a html/JavaScript method?
Method 1. Whenever you can, use ActionScript for communicating with the server. URLLoader and URLRequestMethod, as jhocking said, are the way to go.
Whenever you can’t do something with ActionScript, ExternalInterface provides you all JavaScript power.
For the game closing event (browser tab closing event), you can interface with JavaScript like this:
In JavaScript:
${application}should be substituted with["YourEmbeddedFlashElementName"].