Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to convert score in binary

Explorer ,
Apr 25, 2013 Apr 25, 2013

when i submit score, score send to php file with binary

TOPICS
ActionScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 26, 2013 Apr 26, 2013

use:

var binary_score:String = decimal_score.toString(2);

Translate
Community Expert ,
Apr 26, 2013 Apr 26, 2013

use:

var binary_score:String = decimal_score.toString(2);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2013 Apr 26, 2013

this script use on click submit score

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 27, 2013 Apr 27, 2013

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");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 29, 2013 Apr 29, 2013

once again, thanks Kglad

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2013 Apr 30, 2013

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 04, 2013 May 04, 2013

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;

};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 04, 2013 May 04, 2013

you should use the code i showed but, to change your code:

loc1.playerScore = score.toString(2);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 06, 2013 May 06, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2013 May 07, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines