Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / August 2006



Tip: Looking for answers? Try searching our database.

PHP <--> flash

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Shin_Ares - 25 Aug 2006 15:36 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.