I'm trying to retrieve a score from a database, hold it in a variable and then use it within other action script functions.
I have managed to retrieve the score froom the database just fine, however I am having a problem passing the result from the user_score variable to the score variable so that I can reuse the value throughout the rest of the action script.
Can anyone shed some light on what I'm doing wrong?
Please see the snippet below:
//Get The Score from the database
var variables:URLVariables = new URLVariables();
var request:URLRequest = new URLRequest();
request.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
request.url = "http://www.operationclimatechange.com.au/layer/ws/xFlashScore.php";
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Function to Get Score of the logged in user and store it in a variable called "score"
// Score Scale //
//score user earns in missions
var total_balloons=1400;//total balloons available 1200
var balloons=0;// balloons earnt or lost in the game for each object
var user_balloons=score+balloons;//total ballons won or lost during game
In your complehandler() method you are setting the value of user_score=score after initializing it with the score you are getting from the database. Later in your code you have declared and initialized score with a value 0.
Cheers! I have effectively written over the user_score with 0. I managed to create another function and pass the user_score value to the score variable. I think it's working for the time being, however I may be back in a couple of hours