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

How to echo a Flash variable in Php

New Here ,
Aug 06, 2014 Aug 06, 2014

Okays.Let me start off by saying,"i am a noob".With that said,just ignore my poor explanation.I ve' been struggling to figure out what it is that is missing in my incoherent AS2 codes. What i am trying to achieve is very simple yet,confusing as i am still very new to several statements in AS2. My code below is accepting input from user(s).Then sends entered input to a Php file...which in-turns prints the entry in a new window.(some kinda test i choose to do).

AS 2 code --->

stop();

      submit_btn.onRelease = function() {

    if (Age_txt.text != '') {


var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

   send_lv.numby =Age_txt.text;

  send_lv.sendAndLoad("goto.php", receive_lv, "POST");

     getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

Php goes like -->  <goto.php>

<?PHP

$catch=$_POST['numby'];

$hollaback='your fake age is $catch';

if($_POST[numby]) {

echo $hollaback ;

  }else {

         echo "you have entered nothing"; } 

?>

PS: The getURL() in my line 8 is just my way of forcing 'goto.php' to tell me what it caught in it's memory. I do not wish to send the msg back to flash via error_box.

                                                                                                          THANKS ALOT PEOPLES!

TOPICS
ActionScript
1.5K
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 06, 2014 Aug 06, 2014
use:

stop();

var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

receive_lv.onData=function(src:String){

trace(src);  // or use a textfield to display those echos

}

      submit_btn.onRelease = function() {

trace("sending "+Age_txt.text);  // for debugging

    if (Age_txt.text != '') {



   send_lv.numby =Age_txt.text;

  send_lv.sendAndLoad("goto.php", receive_lv, "POST");

   //  getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

Php goes like -->  <goto.php>

<?PHP

$catch=$_POST['numby'];

$hollaback='your fake age is $catch';

if($_POST[numby]) {

echo $hollaback ;

  }else {

         echo "you have entered nothing"; } 

?>

PS: The getURL() in my line 8 is just my way of forcing 'goto.php' to tell me what it caught in it's memory. I do not wish to send the msg back to flash via error_box.

                                                                                                           THANKS ALOT PEOPLES!

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
New Here ,
Aug 07, 2014 Aug 07, 2014

Not trying to be an asse but Php would never print a flash variable with just an ECHO statement especially when the variable would have to be returned to the flash dynamic textfield(error_box) name.

Apart from this, while i am not very sure IF i need the trace(), your code above is correct.And seriously, i am not lazy to try.. it is just not working.I d' suggest(if you have time) for you to do a test run on the above code.. you might u/stand my frustration. However,thanks a bunch..after-all, you r not being paid to help me

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

AGAIN:  trace(src);  // or use a textfield to display those echos

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
New Here ,
Aug 08, 2014 Aug 08, 2014

So,i did all you told me(traced all stages..)the output panel proved good.But php did not receive anything. So i flipped the script from the above into this--->

AS Code [i made changes to onData() by using .onLoad() in Line 4 ]

stop();

var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

send_lv.onLoad = function(ok) {      //trying to make it available for php by onload

  if (ok) {

  error_box.text = 'Going for handshake with php,Thanks!!';     // decided to use textfield to display the echos

  } else {

  (error_box.text='Sorry..No Php');

  }

};

submit_btn.onRelease = function() {

  trace("sending: "+Age_txt.text);

  // for debugging

  if (Age_txt.text != '') {

  send_lv.Age = Age_txt.text;

  trace("Age: "+send_lv.Age);     //  I traced like this: +send_lv.Age instead of this: +Age bcos this: +Age gives an error in the output panel

  send_lv.sendAndLoad("goto.php", "receive_lv", "POST");

  trace(receive_lv);

  //getURL("goto.php", "_blank", "POST");

  } else {

  error_box.text = 'Fill fields correctly';

  }

};

then in Php, i swapped only between  _POST['Age'] for this: _POST['Age_txt] and backwards several times trying diff outcomes..yet NO JOY!

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

no.  you have more than one error.

just copy the code i suggested in message 1.  don't make any changes to my code.

you can add additional code (esp, if you need to use a textfield while testing and/or you want to add more trace functions).

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
New Here ,
Aug 11, 2014 Aug 11, 2014

Went on a break to get a straight head..Using this on php gave me an error.

<?

$catch=$_POST['Age_txt'];

$hollaback='your fake age is $catch';

echo "&ASpipeline=$hollaback&";

?>

I used your code above(with little or no changes made).. ran it on my server. Php would flag back an error.Meanwhile, i saw/found no error from the AS2 code.now i really dont know why the variable isn't echoed back to flash //i used a dynamic txt to display msg..

var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

receive_lv.onData=function(src:String){

  trace(src);

  if (ok) {

   error_box.text = receive_lv.ASpipeline;}

   else{

   error_box.text="error at server end";

   }// or use a textfield to display those echos  

}

      submit_btn.onRelease = function() {

  

trace("caught: "+Age_txt.text);  // for debugging

    if (Age_txt.text != '') {

   send_lv.numby =Age_txt.text;

    send_lv.sendAndLoad("goto.php", receive_lv, "POST");

   //  getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

Now really short of ideas. Is it possible that the Flash player on my pc is the reason why these codes wont run?I use flash 8 professional.

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

now your php code is incorrect.

again, use:

stop();

var send_lv:LoadVars = new LoadVars();

var receive_lv:LoadVars = new LoadVars();

receive_lv.onData=function(src:String){

trace(src);  // or use a textfield to display those echos

}

      submit_btn.onRelease = function() {

trace("sending "+Age_txt.text);  // for debugging

    if (Age_txt.text != '') {

   send_lv.numby =Age_txt.text;

  send_lv.sendAndLoad("goto.php", receive_lv, "POST");

   //  getURL("goto.php", "_blank", "POST");

    } else {

   error_box.text = 'Fill fields correctly';

  }

};

//  <goto.php>

<?PHP

$catch=$_POST['numby'];

$hollaback='your fake age is $catch';

if($_POST[numby]) {

echo $hollaback ;

  }else {

         echo "you have entered nothing"; } 

?>


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
New Here ,
Aug 20, 2014 Aug 20, 2014
LATEST

Sir, I used as described in msg 7 but my swf output panel says "undefined".

Please and please again, what am i missing? Specifically, what is undefined in my AS2 code? Thanks and sorry for my slow assimilation.

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