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

Sending variables from flash AS2 to php mySQL

Community Beginner ,
Aug 16, 2014 Aug 16, 2014

Hi adobe I have a question. So I have finally created a login/register system with php and mysql and flash as2. That works and here is the link:lumosityentertainment.hostei.com/PhPLoginSystem.swf

But I have a question. How do I send variables from flash as2 to my mySQL database? And then how do I load them up from mysql to flash as2? Also when the variables get edited or changed like if I had 6 gold and then now I have 7 gold how do I make flash send that updated data to my database? I know you use php and stuff but can I have examples of easy php and as2 codes? I'm a beginner in php but I know a decent amount of AS2. I've been searching all around google and adobe forums for the answer but none of them really helped. I'm currently working on a flash game on my website and I'm trying to make it so players can save like their gold,armor,weapons etc. and then load them when logging into their accounts.  Here is my game I currently use cookies to save data:

lumosityentertainment.enjin.com/playfantasydreams

TOPICS
ActionScript
3.0K
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 , Aug 17, 2014 Aug 17, 2014

var sendLV:LoadVars=new LoadVars();

var receiveLV:LoadVars=new LoadVars();

receiveLV.onData=function(src:String){

trace(src);  // or whatever for debugging

}

sendLV.somedata=somedata;

sendLV.someotherdata=someotherdata;

sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");

/////////////////////////////////

////

//php

.

.

$somedata=$_POST['somedata'];

$someotherdata=$_POST['someotherdata'];

//write to your sql

if(whatever){

echo 'success';

} else {

echo 'failure';

}

/////////////////////////////////

p.s when using the a

...
Translate
Community Expert ,
Aug 16, 2014 Aug 16, 2014

use the loadvars sendAndLoad method.

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 Beginner ,
Aug 17, 2014 Aug 17, 2014

Like what are the codes I know that you need to do the loadvars and sendAndLoad etc.

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 ,
Aug 17, 2014 Aug 17, 2014

var sendLV:LoadVars=new LoadVars();

var receiveLV:LoadVars=new LoadVars();

receiveLV.onData=function(src:String){

trace(src);  // or whatever for debugging

}

sendLV.somedata=somedata;

sendLV.someotherdata=someotherdata;

sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");

/////////////////////////////////

////

//php

.

.

$somedata=$_POST['somedata'];

$someotherdata=$_POST['someotherdata'];

//write to your sql

if(whatever){

echo 'success';

} else {

echo 'failure';

}

/////////////////////////////////

p.s when using the adobe forums, please mark helpful/correct responses, if there are any.

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 Beginner ,
Aug 17, 2014 Aug 17, 2014

For the php code do I need to add <?php

//all the codes

<?

Like do I need to add the <?php thingy? Becuase you didnt add it in your example. Also whats the difference between GET and POST? And which should I use?

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 ,
Aug 18, 2014 Aug 18, 2014

yes, you need to use a valid php file.

use POST. it uses an associative array and get appends the variable/values to the url.

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 Beginner ,
Aug 18, 2014 Aug 18, 2014

What is the src in your AS2 code? That's really confusing me. Like in trace(src); what's supposed to be the src inside the parenthesis? Is it just some string? Sorry I don't really create that many functions when coding in AS2.

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 Beginner ,
Aug 18, 2014 Aug 18, 2014

Also I know you didn't provide the mySQL database connection which isn't really important for me because what I did was made another php file for the database code and added a require(databaseconnection.php); in the php file with the variables and _POST but I was wondering what is the code to insert the variables into the table in my mySQL database in php? Also whats the code for when the variable changes it updates the data to the database to the variable it was changed to.

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 ,
Aug 18, 2014 Aug 18, 2014

src is a string returned from your php file (including error messages).

there's no way for anyone in this (or any other) forum to determine the answers to your other questions.  you need to understand you database for those answers or hire someone to create the php file needed to add data to your database.

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 Beginner ,
Aug 25, 2014 Aug 25, 2014

what is for example my database user was like exampledatabase user and database password was exampledatabasepassword and etc how would you set up the connection and sending the stuff to my table?

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 Beginner ,
Aug 25, 2014 Aug 25, 2014
LATEST

oh and in your sendLV.sendAndLoad("yourphp.php",receiveLV,"POST");  part of the code. what do you put inside the paranthesis? inside there i know you put the URL but what does recievelv do and what if your php code has GET but you put POST in your as2 code?

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