Skip to main content
spacebaloon
Known Participant
June 8, 2010
Question

Flaw in flash

  • June 8, 2010
  • 6 replies
  • 2814 views

I have been testing all permutations.

Seems that flash has a flaw in it. If you send a simple item to php and get a reply back, it will work. If the php file is doing more than one thing at a time, flash gets lost. So if you do an "include_once" or send an email or access your database, flash will not get the message back. I even tried to send the message to a simple php file for that one to send the message to flash, but as all data is still in the buffer in php, flash cant see it. Flash cant see the wood for the trees.

I also tried it in cs5 with no luck. Seems that Adobe have not found this out.

Two links below are the previous requests on this isue.

http://forums.adobe.com/thread/621845?tstart=0

http://forums.adobe.com/thread/649331?tstart=0

The reason i am wanting this to work, is that this is for a flash form that will enter a new member to my site. So the php script will connect to my database and input the new member details, check for duplicate entries, send a confirmation e-mail for security and then send the relevant info back into flash.

I first thought it was my php script, but i now know that it is flash. I would love it if adobe would do a bug-fix on this. I am using cs4 at the moment, but have tried it in cs5 with the same out come.

This topic has been closed for replies.

6 replies

spacebaloon
Known Participant
June 8, 2010

I dont mind i little bit of banter, but I think that this is a big isue.

Might give it a try, but I dont think that a timer will help.

PHP script :

<?php 
if ($_POST['sendRequest'] == "parse") {
// connect to your MySQL database here
require_once "connect_to_mysql.php";
// Set some values to go into the table fields for this person(record)
  
  //$returnBody = "";
 
  $firstname = $_POST['firstname'];
     $lastname = $_POST['lastname'];
     $country = $_POST['country'];
     $username = $_POST['username'];
     $city = $_POST['city'];
  
  $year = $_POST['year1'];
  $month = $_POST['month1'];
  $day = $_POST['day1'];
  
  $email = $_POST['email'];
     $pass = $_POST['password'];
     $interest = $_POST['areaofinterest'];
  $skillset = $_POST['userskillset'];
  $skilllevel = $_POST['userskilllevel'];

     $firstname = stripslashes($firstname);
     $lastname = stripslashes($lastname);
     $username = stripslashes($username);
     $city = stripslashes($city);
     $email = stripslashes($email);
     $pass = stripslashes($pass);

     $firstname = strip_tags($firstname);
  $lastname = strip_tags($lastname);
     $username = strip_tags($username);
     $city = strip_tags($city);
     $email = strip_tags($email);
     $pass = strip_tags($pass);


  $dob =  "$year-$month-$day";


  $emailCHecker = mysqli_real_escape_string($myConnection,$email);
  $emailCHecker = eregi_replace("`", "", $emailCHecker);
     // Database duplicate e-mail check setup for use below in the error handling if else conditionals
     $sql_email_check = mysqli_query($myConnection,"SELECT email FROM myMembers WHERE email='$emailCHecker'");
     $email_check = mysqli_num_rows($sql_email_check); 
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  $firstname = mysqli_real_escape_string($myConnection,$firstname);
  $lastname = mysqli_real_escape_string($myConnection,$lastname);
     $username = mysqli_real_escape_string($myConnection,$username);
     $city = mysqli_real_escape_string($myConnection,$city);
     $email = mysqli_real_escape_string($myConnection,$email);
     $pass = mysqli_real_escape_string($myConnection,$pass);
 
  $firstname = eregi_replace("`", "", $firstname);
  $lastname = eregi_replace("`", "", $lastname);
  $username = eregi_replace("`", "", $username);
  $city = eregi_replace("`", "", $city);
  $email = eregi_replace("`", "", $email);
  $pass = eregi_replace("`", "", $pass);

     $db_password = md5($pass);

// Build the sql command string
$sqlCommand = "INSERT INTO myMembers (user_name, firstname, lastname, email, password, country, city, interest, skill_set, skill_level, date_of_birth, sign_up_date)
     VALUES('$username','$firstname','$lastname','$email','$db_password','$country','$city','$interest','$skillset','$skilllevel','$dob', now())";
// Execute the query here now

$query = mysqli_query( $myConnection, $sqlCommand) or die (mysqli_error($myConnection));

// Attain the auto-incremented id field automatically if needed here
$id = mysqli_insert_id($myConnection);

mkdir("members/$id",0777);

//!!!!!!!!!!!!!!!!!!!!!!!!!    Email User the activation link    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    $to = "$email";
          
    $from = "admin@xxxxxxxxxx.com";
    $subject = "Complete registration";
    //Begin HTML Email Message
    $message = "Welcome $firstname,

Do not reply to this E-mail.

   Complete this step to activate your login identity at online-studios.

   Click the line below to activate when ready.

   http://www.xxxxxxxxxx.com/activate/activation.php?id=$id&sequence=$db_password
   If the URL above is not an active link, please copy and paste it into your browser address bar

   Login after successful activation using your: 
   E-mail Address: $email
   Password: $pass

   See you on the site!
   admin@xxxxxxxxxx.com";
   //end of message
$headers  = "From: $from\r\n";
    $headers .= "Content-type: text\r\n";

    mail($to, $subject, $message, $headers);

   $returnBody = "<h2>One Last Step - Activate through Email</h2><h4>OK $firstname, one last step to verify your email identity:</h4><br />
   In a moment you will be sent an Activation link to your email address.<br /><br />
   <br />
   <strong><font color=\"#990000\">VERY IMPORTANT:</font></strong>
   If you check your email with your host providers default email application, there may be issues with seeing the email contents.  If this happens to you and you cannot read the message to activate, download the file and open using a text editor. If you still cannot see the activation link, contact site admin and briefly discuss the issue.<br /><br />
   ";

// Echo output showing success and new user ID number
print "returnBody=$returnBody";
// close mysql connection
mysqli_close($myConnection);
exit();
}
?>

Flash script :


stop();


////// Set text formatting colors for errors, waiting..., and success mechanisms
var errorsFormat:TextFormat = new TextFormat();
errorsFormat.color=0xFF0000;

var waitingFormat:TextFormat = new TextFormat();
waitingFormat.color=0x339900;

var successFormat:TextFormat = new TextFormat();
successFormat.color=0x3366FF;

////// Assign a variable name for our URLVariables object
var variables:URLVariables = new URLVariables();
var varSend:URLRequest=new URLRequest("
http://www.xxxxxxxxxx.com/create_member.php");
varSend.method=URLRequestMethod.POST;
varSend.data=variables;

//////// Build the varLoader variable
var varLoader:URLLoader=new URLLoader  ;
varLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);

///// Ready the variables for sending
variables.firstname=info_mc.firstNameTXT.text;
variables.lastname=info_mc.lastNameTXT.text;
variables.email=info_mc.eMailTXT.text;
variables.password=info_mc.password_1TXT.text;
variables.username=info_mc.userNameTXT.text;
variables.city=info_mc.cityTXT.text;
variables.country=info_mc.cb_country.value;
variables.day1=info_mc.cb_day.value;
variables.month1=info_mc.cb_month.value;
variables.year1=info_mc.cb_year.value;
variables.areaofinterest=skills_mc.cart_txt.text;
variables.userskillset=skills_mc.cart2_txt.text;
variables.userskilllevel=skills_mc.RadioButtonGroup2.selection.label;
variables.sendRequest="parse";

output_txt.text="";
//////// Handler for PHP script completion and return
function completeHandler(event:Event):void {

skills_mc.status_txt.text="";

if (event.target.data.returnBody=="") {
output_txt.text="No data coming through";
//MovieClip(parent.parent).gotoAndStop("_home");
} else if(event.target.data.returnBody!=="") {
output_txt.condenseWhite = true;
         output_txt.htmlText = ""+ event.target.data.returnBody;
//skills_mc.status_txt.text="";
gotoAndStop("_end");
}
trace(varLoader.data.status)
}

// Send the data to the php file
varLoader.load(varSend);
trace(varLoader.data.status)
skills_mc.status_txt.text="processing...    Please wait.";
skills_mc.status_txt.setTextFormat(waitingFormat);

Inspiring
June 8, 2010

What will be trace if you do:

function completeHandler(event:Event):void {
    trace(event.target.data);
}

Although I don't know PHP, is it a right way to output return variables using print? I see examples that use arrays and echo:

echo "returnBody=$returnBody";

In addition, I suggest you use ampersand before the variable:

echo "&returnBody=$returnBody";

or

print "&returnBody=$returnBody";

If all this doesn't work, what will happen if you hardcode return variables for testing:

echo "&returnBody='BODY'&var1='var 1'&va2='VAR 2'"; ? Will you be able to read them in Flash?

spacebaloon
Known Participant
June 9, 2010

print  or  echo, makes no difference for me, and adding "&" has the revers effect than what is needed.

hardcoding return variables dose not help me niether.

So flash IS flawed in this matter !!

I have found a possible workround, but not sure yet. I was told about "amfphp" by a friend,so will look into it, but by all rights, flash should be able to do it on it´s own.

ADOBE  ------    FIX IT PLEASE  !!

spacebaloon
Known Participant
June 8, 2010

Granted, I am not an expert, but as far as i can tell the code is fine.

I will gladly put up my scripts to let you all see.

I have been looking into this now for a few months getting bounced from one idea to another by people who seem to know their stuff, but cant see this.

I am not trying to say that they were idiots or anything like that, just that this seems to me to be something that in most peoples mind´s dose not exest.

"HOW DARE HE SAY THAT FLASH HAS A FLAW" . If i am wrong, then so be it, but I have not found anything to say otherwise yet.

spacebaloon
Known Participant
June 8, 2010

Thanks for the input.

To clarify, i have tested this with other peoples flash file´s as well. I took a working flash file and re-directed it to my php, same results.

I am able to populate my database, send email and evrything else that i need, so flash is talking to php, but for some reason flash cant see the incoming information if php is doing more than the initial variables back and forth.

By all meens test it your selves and correct me, but i just want a solution to this as i seem not to be the only one with this problem. Many people cant see or understand the problem at all. I spent a whole night just testing this out.

I still think it is flash, but if someone has a full working example ( with multiple php actions in one ) then please let me see.

Inspiring
June 8, 2010

I hope you realize that web is a stateless entity. Unless you use an advanced streaming technology Flash can see only one thing pre request. Flash sends requests --> it gets back what comes --> SILENCE! CONNECTION DOESN'T EXIST ANY LONGER. NOTHING ELSE HAPPENS until you send another request.

Your posts don't demonstrate a clear understanding of how things work. If this is a wrong impressions - you need to be more specific about concepts you want to implement and what is not working. Otherwise, again, it seems that there is a flaw in application/server side logic.

June 8, 2010

Yeah... like other have said this is your issue not Flash's or PHP. I do database stuff all the time with Flash and PHP. Read some tutorials on server side scripting and Flash - there are plenty of them. And FWIW - timer events are not the right way to do this. You use Flash's event system as server calls are asynchronous.

June 8, 2010

Hi dmennenoh

Normally I would agree with you, but I've experienced in CS4, that

the loader.data could 'hang' unless a timerEvent rechecked the

if( resp_status == "yes" ) ...

Since he had some problems getting ANY response, I just thought

it was prudent to mention, that it could be a possible problem.

Anyway...Let's all smile and be happy...Noone is forcing an

answer out of anybody, right?

June 8, 2010

I've not had any issue with the event system not working when using SS scripts, or any other time. It's been very reliable for me. But yeah, do whatever works for you... but whatever the OP is doing is just plain wrong...

Inspiring
June 8, 2010

What you describe has nothing to do with Flash. It most certainly has nothing to do Flash IDE version. Flash IDE is just a compiler. Also there is no connection between php and Flash - these are totally different, independent technologies.

What you call "bug" is not Flash's fault. There is something wrong with the logic and code.

People implement extremely complex transactions using Flash. AS3 and server side technologies with no problems all the time.

June 8, 2010

Hi

You need to look at timer events..

Use the timer event to check whether the result is success or not.

Best regards

Peter