Hi Guys,
I got a problem on how to send variable in and out within PHP and Flash. I
tried to follow the tutorial posted in this website but it doesnt work (the
tutorial used loadvarnum).
What I have done here is :
- Flash page (called : tessend.html) send a variable (called : name) to php
file (called : sendtoflash.php)
- I put the code below in the tessend.html (mc_button_submit_vars is a button):
mc_button_submit_vars.onPress = function ()
{
getURL ("sendtoflash.php", "_self", "POST");
};
- In sendtoflash.php, I put :
<?
$dataForTxtbox_1 = "Tes";
print("&textbData1=$dataForTxtbox_1");
echo "<script>";
echo "location = 'mydata.html'";
echo "</script>";
?>
- PHP file then calls the flash file : mydata.html.....the code inside
mydata.html is
myData = new LoadVars();
myData.onLoad = function(){
placeTheDataIntoTheRightPlace();//call the function
};
myData.load("http://localhost/sendtoflash.php");
placeTheDataIntoTheRightPlace = function(){
txtBox1.text = myData.textbData1;
};
It does work well. But if I change the sendtoflash.php file into :
<?
$dataForTxtbox_1 = $_POST['name'];
print("&textbData1=$dataForTxtbox_1");
echo "<script>";
echo "location = 'mydata.html'";
echo "</script>";
?>
this doesnt work.......
Is there anybody can help me? I posted this question in other forum but
couldnt get a correct solution....
I just read the tutorial in the adobe.com about sendandload but it doesnt work
as well... in fact there is another person who has the same problem as mine....
Please give me any advice and detail explanation...:(
thank you
Motion Maker - 26 Aug 2006 17:09 GMT
If you are sending Url Var data to a server side script, you need to use
LoadVars.sendAndLoad and not LoadVars.load.
The example in Flash online help will give you the template:
http://livedocs.macromedia.com/flash/8/main/00002336.html
One other item is when you assign a function at runtime to a variable as in
placeTheDataIntoTheRightPlace = function() you want to do this before it is
possible that it could be called. It is possible that the load calls onLoad
before the clock tick gets to the assignment line leaving you open for the
variable being undefined. Move the assignment to before the onLoad or
declare the function with function placeTheDataIntoTheRightPlace() so Flash
registers it before running the code.

Signature
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
> Hi Guys,
>
[quoted text clipped - 57 lines]
>
> thank you