|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hey guys,
Got a slight problem. I am trying to send a variable set in flash to a php script on my server, using this code: on (release) { myDirectory = "../CF" loadVariables("../PHP/trans_file.php", "POST"); getURL("../PHP/trans_file.php", "blank") } The problem is that i don't think the variable is being picked up by the php. It looks to me as if i have got the code sending the variable 'myDirectory' to thr PHP fine. But then when i call the 'getURL' this scraps the variable set and reloads the PHP. How can i code it so that it opens and sends the variable at the same time?? Thanks, neb |
|
#2
|
|||
|
|||
|
i'm not very experienced yet in flash to php, but this is what i use:
content = "something"; loadVariablesNum ("write.php", 0, "POST"); now in ur php script, $content contains ur value. i have my .swf and php file in the same location. also make sure if u want to write something to a file or something like that, that u set the permissions rigth. (by default i think) there are no rights to write something to a file. hope this helps... Koala |
|
#3
|
|||
|
|||
|
hey, my first post!
not 100% on what you need exactly, but the way i would, and do, do it is... // create an empty loadVars object // myLoadVars=new LoadVars(); // //add your variable to the object, obviously add as many vars as you need like this // myLoadVars.myDirectory=" ../CF"; myLoadvars.somethingElse="blah blah"; // // use sendAndLoad to call the php script // myLoadVars.sendAndLoad("../PHP/trans_file.php", myLoadVars, "POST"); // myLoadVars.onLoad=doSuccessFunction; // function doSuccessFunction(){ // do something with returned data here!! // even if its just confirm success } in php, access the POSTED var(s) by using PHP Code:
in your case, PHP Code:
what ever is echo'd back by your script will be returned to flash inside the LoadVars object you created and can be accessed with the same dot notation - the object vars[not just values!] are replaced by the echo'd values. if you need to return more than one var, then you will need to concatenate with '&' in php like this thing="ooga booga"&description="wahwahwah" so that flash can understand it therefore myLoadVars will now be an object containing myLoadVars.thing="ooga booga"; myLoadVars.description="whawahwah"; hope this helps/isnt too condescending ![]()
__________________
beware of geeks bearing animated gifs. |
|
#4
|
|||
|
|||
|
if you just need to send a variable and open the page use
myLoadVars=new LoadVars(); // //add your variable to the object, obviously add as many vars as you need like this // myLoadVars.myDirectory=" ../CF"; myLoadvars.somethingElse="blah blah"; // myloadVars.send("../PHP/trans_file.php", "_blank", "POST"); and one final thing is if you intend sending an array from flash like myLoadvars.myArray[0]="blah"; .... myLoadvars.myArray[7]="blah blah blahdy blah"; it will be sent comma delimited like blah,.,.,.,.,blah blah blahdy blah so you will have to use the following to turn it back into an array PHP Code:
Last edited by mushie : September 4th, 2003 at 10:11 AM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > loadingVariables & opening URL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|