Copy link to clipboard
Copied
when i submit score, score send to php file with binary
use:
var binary_score:String = decimal_score.toString(2);
Copy link to clipboard
Copied
use:
var binary_score:String = decimal_score.toString(2);
Copy link to clipboard
Copied
this script use on click submit score
Copy link to clipboard
Copied
var sendLV:LoadVars=new LoadVars();
receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src):Void{
//do whatever with return from php
}
yourbutton.onClick=function(){
sendLV.binary_score=decimal_score.toString(2);
sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");
}
Copy link to clipboard
Copied
once again, thanks Kglad
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Hi Kglad,
this my function for send score button
i want to score convert into binary
my_btn.onRelease = function ()
{
var _loc1 = new LoadVars();
_loc1.playerName = "your";
_loc1.playerScore = score;
loc1.send("score-board.php", "parent", "POST");
score=score*200-50+75;
};
Copy link to clipboard
Copied
you should use the code i showed but, to change your code:
loc1.playerScore = score.toString(2);
Copy link to clipboard
Copied
it's not working.
in php shown same score when submit
score=1000;
var oNumber = score;
var bin = "";
my_btn.onRelease = function ()
{
score=score*200-50+75;
while (score>0) {
if (score%2) {
bin = "1"+bin;
} else {
bin = "0"+bin;
}
score = Math.floor(score/2);
}
return score.toString(2);
var _loc1 = new LoadVars();
_loc1.playerName = "your";
_loc1.playerScore = score;
_loc1.send("score-board.php", "_parent", "POST");
};
i use this code but output is always 0
even it's not send to php file
Copy link to clipboard
Copied
again, use:
var sendLV:LoadVars=new LoadVars();
receiveLV:LoadVars=new LoadVars();
receiveLV.onData=function(src):Void{
//do whatever with return from php
}
yourbutton.onClick=function(){
sendLV.binary_score=decimal_score.toString(2);
sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");
}
and debug your php by checking src in onData.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now