PDA

View Full Version : swf is not recieving sendAndLoad variables


dougevans
05-26-2010, 08:16 PM
Hello All,

I am using the sendAndLoad class to perform a script through PHP and load the variables back into the swf. Using Firefox Firebug, I am able to tell that everything is executing correctly, including the PHP script returning the following variables:

&mySubscriberID=36&firstName=Bill

But the variables are not making it back into the swf file. Here is the code for the first frame of my flash file:


stop();
var sendLV = new LoadVars();
var recLV = new LoadVars();

recLV.onLoad = function(success:Boolean){
trace("recLV back from php");
}

sendLV.onLoad = function(success:Boolean){
nextFrame();
trace("sendLV back from php");
}
sendLV.sendAndLoad("connect7a.php",recLV);



and here is frame 2:

stop();

recLV.createTextField("t_txt", 1, 100, 100, 1, 1);
recLV.t_txt.autoSize = true;

recLV.t_txt.text = "My email address is " + recLV.emailaddress + ".\n";
recLV.t_txt.text += "My subscriber id is " + recLV.mySubscriberID + ".\n";
recLV.t_txt.text += "My first name is " + recLV.firstName + ".\n";


And here is the PHP code:

<?php
$emailaddress='bill@mydomain.com';
$dbhost='localhost';
$username='myuser';
$password='mypass';
$database='mydb';

$conn = mysql_connect($dbhost,$username,$password) or die ('Error connecting to mysql');

mysql_select_db($database) or die ('Unable to select database');

$result = mysql_query("SELECT * FROM email_list_subscribers WHERE emailaddress='$emailaddress'")
or die(mysql_error());

$row = mysql_fetch_array( $result );

$subscriberid = $row['subscriberid'];

$sql = 'SELECT * FROM email_subscribers_data WHERE subscriberid = "' . $row['subscriberid'] . '"';
$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array( $result )) {

if($row['fieldid']==2) {
$fname = $row['data'];
echo "&mySubscriberID=$subscriberid&firstName=$fname";
}
}

?>

I also have dynamic text fields with the above variables assigned to them. Any ideas on why the swf is not receiving the data? ANY help at all would be appreciated. Thanks in advance!

Cota
05-26-2010, 08:19 PM
Think thats because on frame 2 your LoadVars object is gone. Doesnt exist anymore.

dougevans
05-26-2010, 08:25 PM
Hi Cota. Thanks for the reply.

I think I understand. What do you suggest? Do I need to create or recreate the:
var recLV = new LoadVars();
on frame 2?

Also, the swf never gets to frame 2. Wouldn't the dynamic text fields with the variables assigned to them (on both frames) be changing from undefined?

dougevans
05-26-2010, 10:48 PM
I found one of the problems. Apparently it is returning variables but in an unusable form. Here is what is returned:

}
Variable _level0.recLV = [object #3, class 'LoadVars'] {
onLoad:[function 'onLoad'],
mySubscriberID:"36",
firstName:"Bill"
}

Using colons instead of equal signs? Anyone see how to change this please?