ILYAS415 Posted February 9, 2008 Share Posted February 9, 2008 Okay ive been playing around with a flash game which i created. The game is integrated into an arcade for a text-based game. Okay basically im trying to get the end scores for the game and send them to a php script. The php script is then meant to process the score and see if the player is worthy enough to be credited money in the actual text-based game. Heres the code which is meant to send information to the php script: _root.finalscore=_root.score; var receiver_lv:LoadVars = new LoadVars(); receiver_lv.onLoad = function(ok){ if(ok){ message.text = receiver_lv.message; score = _root.score; getURL("flashtophp1.php", this, "POST"); }else{ message.text = "There was an error!!"; } } receiver_lv.load("flashtophp1.php"); Okay and heres the php script which then processes it: <? $username= $_SESSION['username']; $score= $_POST['score']; //OKAY THE PROBLEM IS THAT THE SCRIPT READS THE POST VAR AS EMPTY if ($score < "100"){ $msg="You need 100 to win a prize! your score was $score $username"; }else{ $money= $score*5; $msg="You earned £$money ".ucfirst($username).""; mysql_query("UPDATE users SET money=money+'$money' WHERE username='$username'"); } echo "&message=$msg $score"; ?> Well the problem is that the $_POST['score'] var is empty. Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/ Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 I think the best way of doing this is with Javascript http://www.permadi.com/tutorial/flashjscommand/ Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-462788 Share on other sites More sharing options...
cooldude832 Posted February 9, 2008 Share Posted February 9, 2008 Use POST. Flash can send POST or GET data just like a form and then its straightforward Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-462794 Share on other sites More sharing options...
phpSensei Posted February 9, 2008 Share Posted February 9, 2008 Use POST. Flash can send POST or GET data just like a form and then its straightforward Wow, I actually didnt know that. Learned something new today... Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-462802 Share on other sites More sharing options...
cooldude832 Posted February 9, 2008 Share Posted February 9, 2008 POST/GET aren't php unique things they are http type variables its how php uses them that makes them unique. POST & GET is your bridge for most languages Javascript PHP Perl Rails Java Flash ASP ASP.net etc. All have ways of reading post/get Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-462829 Share on other sites More sharing options...
jonniejoejonson Posted February 9, 2008 Share Posted February 9, 2008 You need to echo the return vars to flash like this: echo "&message=".$msg."&score=".$score; otherwise you are only posting one variable 'message' instead of 'message' and 'score' to flash. Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-462836 Share on other sites More sharing options...
ILYAS415 Posted February 11, 2008 Author Share Posted February 11, 2008 Jonnie i dont think thats right. Basically im trying to send the score variable to the php script. Also i am already posting vars to php script... getURL("flashtophp1.php", this, "POST"); thanks, Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-463553 Share on other sites More sharing options...
Kingy Posted February 11, 2008 Share Posted February 11, 2008 i don't know if this is what you really want, but couldn't u put the score in the url and then just get it using php. flashtophp1.php?score=125 $score = $_GET['score']; then carry on? Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-463557 Share on other sites More sharing options...
phpSensei Posted February 11, 2008 Share Posted February 11, 2008 i don't know if this is what you really want, but couldn't u put the score in the url and then just get it using php. flashtophp1.php?score=125 $score = $_GET['score']; then carry on? That method is always possible, but with the $_POST you have less of a security risk. Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-463561 Share on other sites More sharing options...
tibberous Posted February 11, 2008 Share Posted February 11, 2008 To get data into your Flash application you can you XML sockets. One of the first big things I made in Flash used Flash sockets to communicate to a C++ socket server. However you do it, I would recommend against using Javascript - just introduces too many browser support issues. Quote Link to comment https://forums.phpfreaks.com/topic/90266-flash-to-php-interaction/#findComment-463566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.