[quoted text, click to view] SkidOvidiu wrote:
> what I dont know is how to load/change php variabiles from flash mx
I go into this in much more detail in the book, but the basic principle
is this:
From PHP, you must send a single string of name/value pairs, separated
by ampersands (&). There must be no spaces or characters that cannot be
used in a URL, so you need to pass each of the values to urlencode. You
can build everything into a single string by using .= (a period followed
by an equal sign), like this:
<?php
$output = 'rock='.urlencode($rockResult);
$output .= '&rap='.urlencode($rapResult);
$output .= '&house='.urlencode($houseResult);
$output .= '&dance='.urlencode($danceResult);
$output .= '&classic='.urlencode($classicResult);
$output .= '&other='.urlencode($otherResult);
echo $output;
?>
When those values are received by Flash, each of the names in the
name/value pairs becomes a property of the LoadVars instance. So you
would adapt the onLoad function I gave you before like this:
getPoll.onLoad = function(success) {
if (success) {
rock_txt.text = this.rock;
rap_txt.text = this.rap;
house_txt.text = this.house;
dance_txt.text = this.dance;
classic_txt.text = this.classic;
other_txt.text = this.other;
} else {
rock_txt.text = "Couldn't load data";
}
};
The values sent by PHP become properties of the LoadVars instance. In
your case, I created a LoadVars instance called "getPoll". So once the
values have been loaded by Flash, "getPoll.rock" contains the value sent
from PHP as "rock".
I could have used "getPoll" inside the onLoad function, but since the
callback function directly refers to "getPoll", it's simpler to use
"this" instead.
--
David Powers
Author, "Foundation PHP 5 for Flash" (friends of ED)
Co-author "PHP Web Development with DW MX 2004" (Apress)