Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Try It Free
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 31st, 2003, 05:52 AM
nebrekab nebrekab is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 7 nebrekab User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 45 sec
Reputation Power: 0
Unhappy loadingVariables & opening URL

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

Reply With Quote
  #2  
Old August 31st, 2003, 09:55 AM
koalabeer koalabeer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 9 koalabeer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old September 4th, 2003, 09:49 AM
mushie mushie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 58 mushie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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:
 $myPHPvar $_POST["postedVarName"]; 


in your case,
PHP Code:
 $myDirectory $_POST["myDirectory"]; 


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.

Reply With Quote
  #4  
Old September 4th, 2003, 10:04 AM
mushie mushie is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 58 mushie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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:
 $myArray=explode(",",$_POST["myArray"]); 

Last edited by mushie : September 4th, 2003 at 10:11 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > loadingVariables & opening URL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway